how to get format using the values?
Results 1 to 4 of 4

Thread: how to get format using the values?

  1. #1
    Senior Member
    Join Date
    Sep 2008
    Posts
    123

    how to get format using the values?

    Hi all,

    I need some help with my php script. I'm working on the script to parsing the time from my other script so I can convert the hours into format, example: the hours I parse is 1:00 AM so I can convert it to 20140427010000.


    Here is the list of format for 3 channels:

    Code:
    20140427010000
        
        20140427013000
        
        20140427020000
        
        20140427023000
        
        20140428063000
        
        20140428070000
        
        20140428103000
        
        20140428133200
        
        20140428170000
        
        20140429120000
        
        20140429123000
        
        20140429130000
        
        20140429133000
        
        20140429140000
    
        20140426210000
        
        20140426220000
        
        20140426230000
        
        20140427000000
        
        20140427003500
        
        20140427013700
        
        20140427023700
        
        20140427070000
        
        20140428000000
        20140428013000
        
        20140428050000
        
        20140428060000
        
        20140428070000
        
        20140429000000
        
        20140429030000
        
        20140429060000
        
        20140429063000
        
        20140429070000
        
        20140426210000
        
        20140426220000
        
        20140426223000
        
        20140426230000
        
        20140427000000
        
        20140427010000
        
        20140427013000
        
        20140427020000
        
        20140427030000
        
        20140428000000
    
        20140428010000
        
        20140428020000
        
        20140428030000
        
        20140428040000
        
        20140429000000
        
        20140429010000
        
        20140429020000
        
        20140429030000
        
        20140429040000


    Here is the PHP:

    Code:
    <?php
        ini_set('max_execution_time', 300);
        $errmsg_arr = array();
        $errflag = false;
        include ('simple_html_dom.php');
        
        function getState($string)
        {
          $ex = explode(" ",$string);
          return $ex[1];
        }
        
        $xml .= '<?xml version="1.0" encoding="UTF-8" ?>';
        $xml .= '
        <tv generator-info-name="www.mysite.com/xmltv">';
        $base1 = "http://www.mysite.com/get-listing.php";
        $html = file_get_html($base1);    
        $i = 0;
        
        foreach($html->find('p[id=links]') as $element)
        {
          $program_list[ $count ] = array();
          $id_split = explode("?", $element->plaintext);
          $id_split = explode("&", $link_split[1]);
          $channels = explode("channels=",$id_split[0]);
          $channels = $channels[1];
          $id = explode("id=",$id_split[1]);
          $id = $id[1];
        
          //channels
          //$channel_test = $html->find('p[id=channels]', 10)->plaintext;
          //echo $channel_test;
        
          $program_list[$count]['channels'] = $channels;
          $program_list[$count]['id'] = $id;
        
          $channels_split = explode("?", $element->plaintext);
          $channels_split = explode("&", $channels_split[1]);
          $channel_id = explode("channels=",$channels_split[0]);
          $channel_id = $channel_id[1];
          $my_id = explode("id=",$channels_split[1]);
          $my_id = $my_id[1];
        
          $channel = urlencode($channel_id);
          $id_1 = urlencode($my_id);
          $html_two = file_get_html("http://www.mysite.com/get-listing.php?channels=" . $channel . "&id=" . $my_id);
          $time1 = $html_two->find('span[id=time1]',0)->plaintext;
          $time2 = $html_two->find('span[id=time2]',0)->plaintext;
          $time3 = $html_two->find('span[id=time3]',0)->plaintext;
          $time4 = $html_two->find('span[id=time4]',0)->plaintext;
          $time5 = $html_two->find('span[id=time5]',0)->plaintext;
          $time6 = $html_two->find('span[id=time6]',0)->plaintext;
          $time7 = $html_two->find('span[id=time7]',0)->plaintext;
          $time8 = $html_two->find('span[id=time8]',0)->plaintext;
          $time9 = $html_two->find('span[id=time9]',0)->plaintext;
          $time10 = $html_two->find('span[id=time10]',0)->plaintext;
          $time11 = $html_two->find('span[id=time11]',0)->plaintext;
          $time12 = $html_two->find('span[id=time12]',0)->plaintext;
          $time13 = $html_two->find('span[id=time13]',0)->plaintext;
          $time14 = $html_two->find('span[id=time14]',0)->plaintext;
        
        
          $array = array(
            $time1,
            $time2,
            $time3,
            $time4,
            $time5,
            $time6,
            $time7,
            $time8,
            $time9,
            $time10,
            $time11,
            $time12,
            $time13,
            $time14,
          );
        
          // Save the output format
          $DATE_FORMAT_STRING = "YmdHis";
        
          // GET the current STAGE
          $current_state = getState($array[0]);
          $offset = 0;
        
          foreach($array as $time)
          {
            // Get the item state.  
            $this_state = getState($time);
        
            // check if we past a day? 
            if($current_state == "PM" && $this_state == "AM")
            {
              $offset++;
            }
            $this_unix = strtotime($time) + (60 * 60 * 24 * $offset);
            echo date($DATE_FORMAT_STRING, $this_unix);
            echo "<br></br>";
            $current_state = $this_state;
          }
        }
        ?>


    I want to know how do you get each of those format to output them in the xml start="" and end="" like this?


    Code:
       <?xml version="1.0" encoding="UTF-8" ?>
        <tv generator-info-name="www.mysite.com/XML">
          <programme channel='test start='20140427010000' stop='20140427013000'>
            <title lang="en"></title>
            <sub-title lang="en"></sub-title>
            <desc lang="en"> </desc>
            <category lang="en"></category>
          </programme>
          <programme channel='test start='20140427013000' stop='20140427020000'>
            <title lang="en"></title>
            <sub-title lang="en"></sub-title>
            <desc lang="en"> </desc>
            <category lang="en"></category>
          </programme>
          <programme channel='test start='20140427020000' stop='20140427023000'>
            <title lang="en"></title>
            <sub-title lang="en"></sub-title>
            <desc lang="en"> </desc>
            <category lang="en"></category>
          </programme>
          <programme channel='test start='20140427023000' stop='20140428063000'>
            <title lang="en"></title>
            <sub-title lang="en"></sub-title>
            <desc lang="en"> </desc>
            <category lang="en"></category>
          </programme>
          <programme channel='test start='20140428063000' stop='20140428070000'>
            <title lang="en"></title>
            <sub-title lang="en"></sub-title>
            <desc lang="en"> </desc>
            <category lang="en"></category>
          </programme>
          </tv>


    I tried to use the values, but I will get the wrong format and the format will get mess up if I use the values.

    Does anyone know how I can get the format for per channel using with the values if that is possible?

  2. #2
    Senior Member
    Join Date
    Sep 2008
    Posts
    123
    does anyone know????????????

  3. #3
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,714
    Add them to your $xml variable .... ?
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  4. #4
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,883
    And you might want to explain "get the format". You chose the format in your "other script"; don't you remember what you used? Or does "format" mean something different for you than it does for other people?

    And are you really hosted on mysite.com, or did you mean to write www.example.com ?
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •