Page 1 of 1

Php timezones, mysql dates.

Posted: Sun Feb 05, 2006 9:15 am
by burnthewitches
Hi,

I use putenv('TZ= to change the time zone in a script...

what I want is to find the time difference between mysql and the new time from php and use it on mysql...
I don't want to use 'SET time_zone=' in mysql because only works after some version...

iI supose I should do something like:
$mysql_time = mysql datetime
$php_time = date("Y-m-d H:i:s")

now my problem is how to get the time difference between these two so I can use it in a query like:
SELECT now()
and get the same datetime as in php?
(probably use addtime but still I'm very confused! :( )

ps. really sorry if this makes no sense

Posted: Sun Feb 05, 2006 9:45 am
by feyd
it can be suggested that simply storing the unix timestamp from php can work easiest. time() will return the local time, gmmktime() will return the current time in GMT (use this) .. since that is a known reference, you can then use simple math to offset it to any timezone.

Posted: Sun Feb 05, 2006 10:49 am
by burnthewitches
edit: please forget this I'll do this as feyd sugested! ^_^
thnx again feyd! :)