Page 1 of 1

PHP CLOCK

Posted: Wed Apr 01, 2009 10:19 am
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 ?

Re: PHP CLOCK

Posted: Wed Apr 01, 2009 10:27 am
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()).

Re: PHP CLOCK

Posted: Wed Apr 01, 2009 11:45 am
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;
 

Re: PHP CLOCK

Posted: Wed Apr 01, 2009 1:26 pm
by Hilton PRLBET
Thank you both - problem solved !!!