Page 1 of 1

php date() function

Posted: Mon Aug 02, 2010 8:48 am
by heshan
Hi all,

This is the code that displays current date and time according to the GMT time.
How can i convert it to the local date and time?

Code: Select all

<?php
$today = date("d M Y h:i A"); 
echo $today 
?>

Thanks,

Re: php date() function

Posted: Mon Aug 02, 2010 9:42 am
by AbraCadaver
date() is using the local timezone for the server that it is running on. If you want a different timezone:

Code: Select all

date_default_timezone_set()

Re: php date() function

Posted: Tue Aug 03, 2010 7:05 am
by klevis miho
This is what I needed too. I got the time from the server and added or substracted seconds from it, to fit my timezone.
Thnx AbraCadaver