[wp-trac] [WordPress Trac] #25365: timeAgo attribute for revisions produces the wrong result due to misuse of strtotime

WordPress Trac noreply at wordpress.org
Fri Sep 20 10:37:28 UTC 2013


#25365: timeAgo attribute for revisions produces the wrong result due to misuse of
strtotime
--------------------------+-----------------------------
 Reporter:  biranit       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Date/Time     |    Version:  3.6.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 When looking at revisions, the date for each revision appears correctly,
 but the human_time_diff is wrong.

 For example, on a server with timezone UTC+3, the time is now 13:28
 (UTC+3), and looking a revision from 20 Sep 09:41 (UTC+3) shows:

 7 hours ago (20 Sep @ 9:41)

 Where in fact it should be

 4 hours ago (20 Sep @ 9:41)

 The post_date for this revision is: '''2013-09-20 09:41:08'''
 The post_date_gmt for this revision is: '''2013-09-20 06:41:08'''

 (The server timezone is UTC+3, as is the Wordpress option and the php.ini)

 The reason for this bug is in wp-admin/includes/revision.php line 117:


 {{{
 $modified_gmt = strtotime( $revision->post_modified_gmt );
 }}}


 strtotime uses the server's timezone and therefore assumes the strong
 $revision->post_modified_gmt is actually in UTC+3 (the server's timezone).
 To avoid this and ensure the unix timestap is indeed GMT, the line should
 change to:


 {{{
 $modified_gmt = strtotime( $revision->post_modified_gmt . " UTC");
 }}}

 Thank you,

 Biranit

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


More information about the wp-trac mailing list