[wp-trac] [WordPress Trac] #28636: Add functions for working with local dates and times

WordPress Trac noreply at wordpress.org
Wed Jun 25 18:53:32 UTC 2014


#28636: Add functions for working with local dates and times
-------------------------+-----------------------------
 Reporter:  mboynes      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Date/Time    |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Since WordPress sets `date_default_timezone_set( 'UTC' )`, working with
 local dates and times can sometimes be a bit of a nuisance. I'd like to
 propose adding a couple of functions to replace at least `date()` and
 `strtotime()`. We can add replacements for others too, like `mktime()` if
 the interest is there.

 I've put together two proposals for accomplishing this, one using
 `date_default_timezone_set()` to temporarily change the timezone, and
 another (far more complicated version) using `DateTime`/`DateTimeZone`. I
 think the former is preferable, unless anyone has any reasons, performance
 or otherwise, why resetting the default timezone might be a bad thing?

 I'm not married to the function names I chose (`wp_date()` and
 `wp_strtotime()`), so if it would be preferable to name them e.g.
 `wp_local_date()` and `wp_local_strtotime()`, I'm open to it.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28636>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list