Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#5337 closed defect (bug) (invalid)

Wrong timezone with comment_time and the_time since DST ended

Reported by: jrawle Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3.1
Component: General Keywords: time date timezone dst utc
Focuses: Cc:


I am designing a theme where I want the current timezone to be displayed after the time in comment and post timestamps. For example, I use <?php comment_time() ?> with my default time format set to H:i T.

I am in the UK, and until the clocks changed on 28 October everything was fine. Posts or comments written during a summer gave the time as e.g. "14:00 BST" while those written in the winter said "13:00 GMT".

However, since BST ended, I now see "UTC" for all datestamps, irrespective of whether they were posted during the summer or winter. So the two examples given above would now show "14:00 UTC" and "13:00 UTC" respectively, despite the fact that the first one is incorrect. I also don't understand why it switched from using GMT to UTC.

I do not know whether this bug is present in other timezones.

Change History (3)

#1 @jrawle
14 years ago

  • Keywords time date timezone dst utc added
  • Milestone changed from 2.3.2 to 2.4

From the PHP manual http://www.php.net/mktime :


This parameter can be set to 1 if the time is during daylight savings time (DST), 0 if it is not, or -1 (the default) if it is unknown whether the time is within daylight savings time or not. If it's unknown, PHP tries to figure it out itself. This can cause unexpected (but not incorrect) results.

The parameter is deprecated in PHP 5.1.0 and "the new timezone handling features should be used instead."

For servers in the UK, it seems PHP is "figuring out" that they are on British time in the summer, but in the winter it gets it slightly wrong and assumes the machine is permanently on UTC (hence UTC not GMT).

Perhaps this should be addressed in Wordpress along with other issues surrounding timezones, for example automatic DST?

Other timezones could be affected if PHP makes the wrong guess as to the timezone.

#2 @lloydbudd
14 years ago

  • Milestone changed from 2.4 to 2.5

#3 @Viper007Bond
13 years ago

  • Milestone 2.9 deleted
  • Resolution set to invalid
  • Status changed from new to closed

comment_time() reports what your clock said when you wrote the comment. Changing the timezone setting in your settings does not change that value for past comments.

Use the data from the GMT column in the comments object if you wish to ignore or update the timezone.

Note: See TracTickets for help on using tickets.