Displaying current time + 1 hour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Displaying current time + 1 hour

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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);
Post Reply