PHP CLOCK

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
Hilton PRLBET
Forum Newbie
Posts: 2
Joined: Wed Apr 01, 2009 10:15 am

PHP CLOCK

Post by Hilton PRLBET »

Hi All

This is probably a ridiculously easy question but as a non coder I really need your help.
Below is the code my programmer did before he left the company. Problem is that, when the the clocks turned back on Sunday, the time on my website is an hour ahead of the actual time in South Africa ( which is supposed to be GMT +2 )

id="srvdate"><? print date("d F Y H:i:s", time())?>

Does anyone know how or what I need to add to the above or is this coding far too little info for you to work with ?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: PHP CLOCK

Post by John Cartwright »

There are a few example of dealing with daylight savings in the manual - dates. More specifically, you will use date('I') to determine whether you are in daylight savings, and therefore need to make the adjustments (preferably using mktime()).
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: PHP CLOCK

Post by Mark Baker »

Code: Select all

 
$gmtTime = date_create("now", new DateTimezone('GMT'); 
$gmtTime->setTimezone(new DateTimezone('Africa/Johannesburg'); 
$localTime = $gmtTime->format("d F Y H:i:s");  
 
echo $localTime;
 
Hilton PRLBET
Forum Newbie
Posts: 2
Joined: Wed Apr 01, 2009 10:15 am

Re: PHP CLOCK

Post by Hilton PRLBET »

Thank you both - problem solved !!!
Post Reply