How do I convert US date time ( Date Time of the server ) to the local date time for Calcutta, India ? I looked at the gmdate function, but not sure wheather that is the one to do it.
Any help is highly appreciated.
Thanks
kmazumdar
How do I convert US date time ( Date Time of the server ) to the local date time for Calcutta, India ? I looked at the gmdate function, but not sure wheather that is the one to do it.
Any help is highly appreciated.
Thanks
kmazumdar
You can check the mktime() function at:
http://www.php.net/manual/en/function.mktime.php
And the gmstrftime() function at:
http://www.php.net/manual/en/function.gmstrftime.php
A small example is this:
if (date("I") == 0):
$datetime = gmstrftime("%Y-%m-%d %H:%M:%S", mktime(gmstrftime("%H"), gmstrftime("%M"), gmstrftime("%S"), gmstrftime("%m"), gmstrftime("%d"), gmstrftime("%Y")));
else:
$datetime = gmstrftime("%Y-%m-%d %H:%M:%S", mktime(gmstrftime("%H"), gmstrftime("%M"), (gmstrftime("%S")+3600), gmstrftime("%m"), gmstrftime("%d"), gmstrftime("%Y")));
endif;
Little bit complecated huh?
This will output yyyy-mm-dd HH:MM:SS
If you want to change the format in which date is displayed change the:
Y-%m-%d %H:%M:%S
line to whatever you like according to gmstrftime() function settings.
Note that if Daylight time is set then 3.600 secs (1Hour) are added to the time.