[wp-trac] [WordPress Trac] #40653: Use PHP `DateTime` class API in `current_time()`

WordPress Trac noreply at wordpress.org
Fri Jun 29 16:20:33 UTC 2018


#40653: Use PHP `DateTime` class API in `current_time()`
----------------------------------------+------------------------------
 Reporter:  jdgrimes                    |       Owner:  (none)
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Date/Time                   |     Version:  1.0
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------------

Comment (by Rarst):

 Having done some work on `current_time()` today in #37440 and #40657 here
 are my current thoughts:

 1. In GMT mode `current_time()` is not much of a problem. It becomes an
 alias of upstream `time()` and `gmdate()`. Where that is the case we
 should be just eliminating it in favor of calling those directly.
 2. In "local" mode it "works" as long as there is no time zone in format,
 because that one will be wrong. Well and WP timestamp is a disaster.
 However I don't think this is worth fixing ''in'' `current_time()`. We
 already have another [broken] function that knows how to do this —
 `date_i18n()`. If we make a replacement for that one (tentatively
 `wp_date()`) then we can get `current_time()` fixed "for free" by
 upgrading to use it.

 So at the moment I am focusing on reducing the ''usage'' of
 `current_time()` in core and adding unit tests for it.

 I don't think we will be in position to easily drop `current_time()` or
 "fix" it (since local time is broken on design level), but I think we are
 on a good track to downplay its usage and gradually make it a non–issue.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40653#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list