WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#13173 closed defect (bug) (duplicate)

get_date_from_gmt does not properly convert non-DST dates when DST is in effect and vice versa.

Reported by: cfinke Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Date/Time Keywords: reporter-feedback
Focuses: Cc:

Description

If it is May 1 where I am and daylight-savings time is in effect, and I schedule a post for December 1 at noon (when DST is not in effect) via XML-RPC using the date_created_gmt parameter, my post will actually be scheduled for December 1 at 1pm. This is due to the fact that get_date_from_gmt uses the current timezone offset to convert the date from GMT to local time rather than the timezone offset specific to the date it is converting.

The root issue I suppose is that get_option('gmt_offset') doesn't know when it's getting the gmt_offset for. Fixing that would probably fix a number of other daylight-savings time related issues in Wordpress.

Tested in Wordpress 2.9.2 and the current Wordpress.com.

Attachments (1)

13173.patch (2.1 KB) - added by solarissmoke 5 years ago.
Idea for new function that allows getting gmt offset for a past/future timestamp, which is then called from get_date_from_gmt()

Download all attachments as: .zip

Change History (6)

comment:1 @solarissmoke5 years ago

  • Milestone changed from Unassigned to 3.1
  • Version set to 3.0

There is already a pre_option filter on gmt_offset that automatically adjusts the offset for daylight savings - only thing is it assumes you want to know the offset at the time of execution.

I don't think it would be too difficult to add an argument to wp_timezone_override_offset() that allows you to specify a future time for which to calculate an offset. Let me see if I can cobble something together.

comment:2 follow-up: @nacin5 years ago

Isn't this a duplicate of #9285?

@solarissmoke5 years ago

Idea for new function that allows getting gmt offset for a past/future timestamp, which is then called from get_date_from_gmt()

comment:3 in reply to: ↑ 2 @solarissmoke5 years ago

Replying to nacin:

Isn't this a duplicate of #9285?

Possibly, though they are related to different functions. The issue here is that get_date_from_gmt() assumes that the current timezone offset equals the timezone offset for whatever time-string it is given. The issue with #9825 is that get_gmt_from_date() is doing the same thing in reverse.

I think having a get_gmt_offset() function would help fix both of these, rather than having separate timezone-handling code in both of get_date_from_gmt() and get_gmt_from_date(). The main problem is that currently any use of get_option('gmt_offset') assumes that we're dealing with the present.

comment:4 @hakre4 years ago

  • Keywords reporter-feedback added

Please name the PHP version you are experiencing this with and the os and if it's 32 or 64 bit.

comment:5 @nacin4 years ago

  • Milestone Awaiting Triage deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This should be handled by either #9285 or #12610.

Note: See TracTickets for help on using tickets.