Hey guys,
Completely stumped ... heres what I'm trying to do. When I upload a page I want it to say that one of 3 things depending on the upload time:
Upload = current day then
1. i.e uploaded today - it says Uploaded: Today 9.15am
OR Upload = current_date -1 then
2. i.e. uploaded yesterday - it says Uploaded: Yesterday 9.15am
OR upload = any other time
3. i.e. uploaded more than 1 day ago - it says Upload Nove 23, 2004
These customised displays are dependent on the time stamp of the file that is being accessed ... and the server is in the states so all when I update a file here in ireland and upload it to my host who is in the states it appears with an upload time 5hrs behind me, as is expected.
Now my problem is that I convert all the data into GMT (as I'm in Ireland) and then calculate the times from this. Now this scripts works throughout the day ... but at 12am GMT or 7pm EST the wrong data is returned.
At 12am GMT for the 23rd Nov it returns today_day as being the 22nd - and I dont have a clue why since I changed the times/dates into GMT with the function gmmktime() and gmdate()PHP Code:<?php
function last_updated($filename)
{
// Display the date
// eg. Jan 25 2004
$last_modified = filemtime($filename);
$last_modified_day = gmdate("M d Y", $last_modified);
$last_modified_time = gmdate("g:ia", $last_modified);
$today = gmmktime(0,0,0,date("m") ,date("d"),date("Y"));
$today_day = gmdate("M d Y", $today);
$yesterday= gmmktime(0,0,0,date("m"),date("d")-1,date("Y"));
$yesterday_day = gmdate("M d Y", $yesterday);
if ($last_modified_day == $today_day){
$last_modified = 'Today ' . $last_modified_time;
}
elseif ($last_modified_day == $yesterday_day){
$last_modified = 'Yesterday ' . $last_modified_time;
}
else{
$last_modified = $last_modified_day;
}
echo "<b>Last Updated: </b>" . $last_modified;
}
?>
You can see the use of the code here
Any Ideas?
Cheers,
Ronan




Bookmarks