[wp-trac] [WordPress Trac] #39595: date_default_timezone_set in wp-settings.php is set prematurely and ignorantly, regardless of other defined settings

WordPress Trac noreply at wordpress.org
Thu Feb 28 20:11:41 UTC 2019


#39595: date_default_timezone_set in wp-settings.php is set prematurely and
ignorantly, regardless of other defined settings
-------------------------------+----------------------
 Reporter:  mkormendy          |       Owner:  (none)
     Type:  enhancement        |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Date/Time          |     Version:  4.7.1
 Severity:  minor              |  Resolution:  wontfix
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+----------------------

Comment (by kpersson):

 I know this post is closed, I am only adding my workaround for this, in
 case someone googles it like I did.  I added this to my themes
 functions.php  it will return a timestamp anywere in wordpress that I call
 this php function,  or you can use the shortcode.  Then any reference to a
 date or time, I refer to the timestamp and it is correct for the timezone
 you set.

 function displaydate(){
      $date = new DateTime(null, new DateTimeZone('America/Los_Angeles'));
      return ($date->getTimestamp() + $date->getOffset());
 }
 add_shortcode( 'date', 'displaydate' );

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


More information about the wp-trac mailing list