[wp-trac] [WordPress Trac] #28636: Add functions for working with local dates and times
WordPress Trac
noreply at wordpress.org
Thu Nov 20 05:04:09 UTC 2014
#28636: Add functions for working with local dates and times
-----------------------------------+-----------------------------
Reporter: mboynes | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Date/Time | Version: 2.9
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch | Focuses:
-----------------------------------+-----------------------------
Comment (by mboynes):
Here's the use-case which influenced this:
Let's say I have a form with a datepicker, and I want to schedule a cron
event based on the date string I enter, perhaps 2014-11-19 at 23:00. If I
use `strtotime()`, for me in EST, this will end up firing 5 hours earlier
than I'm expecting. `wp_strtotime()` takes the trouble out of doing the
conversion.
I think benefits/use cases for `wp_date()` are probably a bit more
obvious. If I call `date( 'Y-m-d H:i:s' )`, I don't get my current time,
which I think can be confusing for developers. Calling `wp_date( 'Y-m-d
H:i:s' )` simply provides the site's local time. Similarly, you can pass a
timestamp, and you're going to get back the requested date/time format in
the site's local timezone.
Since these aren't going to be used anywhere in core out of the gate, I
don't think there's any harm in including them late in beta, but if you
still want to punt to 4.2, I understand. Let me know if you have any
questions!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28636#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list