views:

81

answers:

1

Hi,

I'm storing the UTC dates into the DB using:

$utc = gmdate("M d Y h:i:s A");

and then I want to convert the saved UTC date to the client's local time.

How can I do that?

Thanks

A: 

date() and localtime() both use the local timezone for the server unless overridden; you can override the timezone used with date_default_timezone_set().

http://www.php.net/manual/en/function.date-default-timezone-set.php

http://us3.php.net/manual/en/function.date.php

http://php.net/manual/en/function.localtime.php

Amber
But how do I get the current UTC timestamp?
Marco
Why do you need the current UTC timestamp to convert the saved UTC timestamp?
Amber
But if you do, `time()` always returns UTC: http://us2.php.net/manual/en/function.time.php
Amber