Skip to content

Issue with timezones in Future Actions #1348

@stevejburge

Description

@stevejburge

https://wordpress.org/support/topic/date-check-issue/

I faced an edge case related to a wrong date check when editing a post if WP’s and your time zones are different.

Example:
WP has time zone set to UTC+0, and mine is UTC+1.
Let’s say UTC+0 time is 1 p.m., so mine is 2 p.m..
I need to schedule publishing in 30 minutes, so I set feature action time to 1:30 p.m. and… get ‘Date cannot be in the past’ error message.

Use case: I created a post in advance, and at the last minute, I realized I had made a mistake in the content. I tried to change it, but I can’t because of the date check issue.

I found the root of the issue: you are comparing dates with no information about the time zone (i.e., new Date(date) < new Date()), but an Action is scheduled by taking it into account. You should append date with a WP’s time zone, so it will be adjusted properly.

P.S.: on a screenshots below you could see a demonstration of the issue:

I have UTC+3 and mine current time is 11:41 a.m.
WP set to UTC+2 and it’s current time is 10:41 a.m.
Future action set to 10:45

Image
Image

Metadata

Metadata

Assignees

Labels

unconfirmed bugThis needs more testing. Can often be used when a member of the public posts.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions