[wp-trac] [WordPress Trac] #4856: Timezone issues

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 29 01:10:22 GMT 2007


#4856: Timezone issues
---------------------+------------------------------------------------------
 Reporter:  Rauchg   |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.2.3    
Component:  General  |     Version:           
 Severity:  normal   |    Keywords:           
---------------------+------------------------------------------------------
 I'm experiencing some issues with Wordpress timezone handling.

 If we have a look at the current_time function, we'll see that when called
 with the 'timestamp' parameter it returns time() plus the GMT offset.

 {{{

 else $d = time() + (get_option('gmt_offset') * 3600);

 }}}

 However, if time() is not really returning the number of seconds till GMT,
 but to the timezone set in the server computer, it returns an incorrect
 value.

 Test code as follows.
 My timezone is GMT - 3. GMT for the example is 00:58:05

 {{{

 echo current_time('mysql');
 echo date('Y-d-m H:i:s', current_time('timestamp'));

 // will return
 // 2007-08-28 21:58:05 (GMT -3: correct)
 // 2007-28-08 18:58:05 (GMT -6!)
 }}}

 The problem has been solved by resetting the TZ enviroment variable.

 {{{

 putenv('TZ=');

 echo current_time('mysql');
 echo date('Y-d-m H:i:s', current_time('timestamp'));

 // returns
 // 2007-08-28 22:02:56 (GMT -3)
 // 2007-28-08 22:02:56 (GMT -3)
 }}}

 My setup:

 {{{
 guillermo-rauchs-computer:~ guillermo$ php -v
 PHP 5.2.2 (cli) (built: May  4 2007 17:56:56)
 }}}

 {{{
 guillermo-rauchs-computer:~ guillermo$ uname -a
 Darwin guillermo-rauchs-computer.local 8.10.1 Darwin Kernel Version
 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386
 i386 i386
 }}}

 Using latest trunk

 Haven't reproduced this in more computers. Can anyone do so?

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4856>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list