Page 1 of 1

Displaying current time + 1 hour

Posted: Wed May 09, 2007 2:57 am
by spacebiscuit
Hi,

I am trying to modify a bit of code which displays the current date and time:

Code: Select all

$curtime = time();
$curdate = date("F j, Y h:i:s A", $curtime);
The time diplayed is one hour behind as it's displaying the server's time. Is it possible to add an hour so that it displays the correct time in my location?

Many thanks,

Rob.

Posted: Wed May 09, 2007 3:20 am
by Kieran Huggins
As of 5.1 you can use date_default_timezone_set() to set your timezone.

Or you could add an hour to the time like so:

Code: Select all

$curtime = strtotime('+1 hour');
$curdate = date("F j, Y h:i:s A", $curtime);