[wp-trac] [WordPress Trac] #48935: Need to Remove strtotime() usage from core (was: Remove strtotime() usage from core)

WordPress Trac noreply at wordpress.org
Thu Apr 6 10:38:44 UTC 2023


#48935: Need to Remove strtotime() usage from core
------------------------------------------+------------------------------
 Reporter:  Rarst                         |       Owner:  (none)
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Date/Time                     |     Version:  6.2
 Severity:  normal                        |  Resolution:
 Keywords:  needs-unit-tests needs-patch  |     Focuses:
------------------------------------------+------------------------------
Changes (by rajanpanchal2028):

 * keywords:  needs-unit-tests has-patch => needs-unit-tests needs-patch
 * version:   => 6.2


Comment:

 Yes @Rarst ,
 The function strtotime() is commonly utilized in the core of PHP for
 handling input that is ambiguous with regards to time zones. However, this
 function is susceptible to the default PHP time zone setting, which is
 initially set to UTC by the core upon boot. As a result, if third-party
 code modifies this setting, it can affect the behavior of strtotime().

 In the 5.3 release, a switch from date() to gmdate() caused new issues
 because changing the default time zone caused problems with the
 combination of strtotime() and date(). Although the output appeared to be
 correct, it was actually in a completely different time zone than
 intended.

 To mitigate this issue, it is recommended to replace the use of
 strtotime() with explicit time zone handling through date parsing, such as
 by using DateTimeImmutable objects. By doing so, the core of PHP can
 become less reliant on the PHP time zone context and therefore more
 resilient to changes in the default time zone setting.

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


More information about the wp-trac mailing list