Page 1 of 1

Time offset on timestamp

Posted: Tue Mar 17, 2009 12:36 am
by richardk
I am trying to add a time offset (+1hr) to this script; can anybody help. The server that hosts this page is in another time zone.

<?php
$filename = 'weather1.txt';
if (file_exists($filename)) {
echo "Last Updated: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

I am takeing a time stamp off the file being uploaded so people looking at the web page can see if the file has been updated as it should be via FTP.

Re: Time offset on timestamp

Posted: Wed Mar 18, 2009 11:37 am
by susrisha

Code: Select all

 
$date = strtotime(date("F d Y H:i:s", strtotime($date_from)) . " +1 hour");
 

Re: Time offset on timestamp

Posted: Wed Mar 18, 2009 2:16 pm
by pickle
susrisha wrote:

Code: Select all

 $date = strtotime(date("F d Y H:i:s", strtotime($date_from)) . " +1 hour"); 
The order of arguments is wrong there, and you don't need 2 calls to strtotime().

Use this:

Code: Select all

$date = date("F d Y H:i:s",strtotime('+1 hour', filemtime($filename)));