No subject

Fri Jan 29 04:20:33 UTC 2010

should be using current_time('timestamp') instead of PHP's time. This
is because Wordpress sets the default timezone to UTC and current_time
offsets the time from what it finds in the gmt_offset setting.

Ok so now lets say I have created a plugin. Its purpose is to log
messages to a log file with a timestamp.

Obviously at this point generating a timestamp with PHP's date
function is going to be incorrect unless of course your timezone is
UTC +0. So to get the correct time I would use current_time, something
date('Y-m-d H:i:s'), current_time('timestamp')

This is all good, all I have to do is update my plugin with any calls
to date or time with current_time.

My question is what about if I use a third party library that makes
calls to time or date and this library is updated by the third party
from time to time so I don't want to modifiy it. How could one avoid a
scenario like this? Is there more to the date/time handling in
Wordpress that I could be missing?

One initial thought is to set the default timezone to the timezone set
in Wordpress settings before a function call from that library and
then set it back to UTC after.



More information about the wp-hackers mailing list