views:

50

answers:

2

This is from my TV guide pagination script (note, the top half is not mentioned as there are no problems with the code in the beginning):

   class paginationData {

private $program; private $channel; private $airdate; private $expiration; private $episode; private $setReminder;

public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder) { $this->program = $program; $this->channel = $channel; $this->airdate = $airdate; $this->expiration = $expiration; $this->episode = $episode; $this->setReminder = $setReminder; $now = time(); }

//This function shows the data public function display() { if((int)date('Ymd') === (int)date('Y-m-d', $airdate)) $dateFormat = 'g:ia'; elseif((int)date('Y') === (int)date('Y', $airdate)) $dateFormat = 'F jS - g:ia'; else $dateFormat = 'F jS, Y - g:ia';

         $airdateFormatted = date($dateFormat, $airdate, $now);

echo ''."\n". ' '.$this->program.''."\n". ' showing on '.$this->channel.''."\n". ' '.date($this->airdate).''."\n". ' '.$this->episode.''."\n". ' '.$this->setReminder.''."\n". ''."\n"; } }

The airdates always render as the following:

      2010-01-26 00:25:00

but I am not sure how to get strtotime used effectively in this.

In an earlier version of the site, before I used pagination, this worked

      if(date('Y-m-d') == date('Y-m-d', $airdate)) {
    // Same date, show only time
    $dateFormat = 'g:ia';
} elseif(date('Y') == date('Y', $airdate)) {
    // Same year, show date without year
    $dateFormat = 'F jS - g:ia';
} else {
    // Other cases, show full date
    $dateFormat = 'F jS, Y - g:ia';
}

$airdateFormatted = date($dateFormat, $airdate);

echo "<tr><td><b>$programme</b></td><td>showing on $channel</td>";
echo "<td>$airdateFormatted</td><td>$episode</td><td>$setreminder</td></tr>";

but I'm not sure how to get $airdateFormatted to work properly in this script, which is a modified version of someone else's script, that I have customised to my needs.

Any help on ensuring that I can get datetime to render as the following:

 January 27th - 9:25am

and not

     2010-01-27 00:25:00

The site's working, it's just the fine detail with regard to thid that I'm struggling with - I have tried for myself, but always end up with undefined errors, so revert back to the default config.

Any help you have would be appreciated.

A: 

make sure to use

strtotime()

on the time they give you, and put that value in your date() call

TravisO
A: 

Where would I put the strtotime?

The full code is here: http://pastebin.com/f20ce8012

John Doe
You should have posted this as a comment to my answer, this isn't a forum, answers get moved around
TravisO