[wp-testers] Date() function

Luke notfornoone at gmail.com
Wed Apr 21 23:23:58 UTC 2010


This totally makes sense, and although I hadn't noticed any side
effects of changing the default timezone it is probably only a matter
of time before something get out of wack. Sorry about the bad advice.


On 22 April 2010 03:48, Otto <otto at ottodestruct.com> wrote:
> Best not to do this, due to plugin and other things going wonky.
>
> Basically, in order to maintain consistency across older PHP 4
> installations, it was decided to have WP force the PHP environment to
> be using UTC dates for everything. Then WordPress itself applies the
> adjustments when needed.
>
> Too many WP plugins (and core code) expect the date functions to
> return UTC dates. If you change it, you may see odd behaviors and
> date/time displays in plugins and other places.
>
> A call to current_time( 'timestamp' ) will give you the current
> timestamp adjusted by the necessary amount to get the correct time
> display. So to get the correct date in WordPress using date(), you'd
> do this:
>
> date('Y-m-d', current_time( 'timestamp' ));
>
> How it breaks down:
> - PHP date and time functions should always give you the info in UTC.
> - current_time( 'timestamp' ) will give you a UTC timestamp adjusted
> by the amount necessary to show the local date.
>
> -Otto
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list