Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#48642 closed defect (bug) (invalid)

Scheduled posts times are displayed incorrectly

Reported by: charveyunm's profile charveyunm Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Date/Time Keywords:
Focuses: Cc:

Description

After 5.3 update our multisite installation is showing incorrect times. Everything selected seems to be displaying a +7 timezone difference. So if a user selects 4:30AM on the site (either in an ACF field or default scheduled publish option) it will show 11:30AM as the display.

Change History (8)

This ticket was mentioned in Slack in #forums by joyously. View the logs.


5 years ago

#2 @davidbaumwald
5 years ago

  • Component changed from General to Date/Time
  • Severity changed from blocker to normal

#3 @Rarst
5 years ago

  • Summary changed from 5.3 Time update breaks site to Scheduled posts times are displayed incorrectly
  1. This is specific to scheduling future posts, correct?
  2. Database values seem to be correct, as you mentioned in comment elsewhere, could you double check that please?
  3. By "display" you mean in WP post editor? Do you use core version of Gutenberg or something else?
  4. What is your exact time zone in settings?
  5. By chance are you changing default PHP time zone anywhere in your code?
  6. Is it possible to check if the issue still happens without ACF involved?

As of right now I cannot reproduce this locally for scheduled posts.

#4 @charveyunm
5 years ago

In testing I think this is actually related to both ACF and the Classic Editor plugin

This is specific to scheduling future posts, correct?
Yes this refers to scheduling future posts on the post edit admin page.

Database values seem to be correct, as you mentioned in comment elsewhere, could you double check that please?

The database actually lists the post date as the future time (I chose 13:00 and it set it to 20:00) but as far as what the cron gets i'm not sure i can decipher the wp_options cron option enough to actually tell when it will fire. My only knowledge of it actually firing on the time i assign from the drop down is just trying it, I set it, it says the wrong thing but actually executes when i selected it.

In ACF Pro's case - the database is storing the correct time - if I choose 12:00AM - database entry is 00:00:00 if i choose 2AM it's 02:00:00 - the display on the front end though is 7AM and 9PM respectively.

By "display" you mean in WP post editor? Do you use core version of Gutenberg or something else?
We use a combination of Advanced Custom Fields and the classic editor plugin (may be related to classic editor)

What is your exact time zone in settings?
We have our set to Denver

By chance are you changing default PHP time zone anywhere in your code?
No we were allowing WordPress to control our timezone.

Is it possible to check if the issue still happens without ACF involved?
I actually turned off classic editor and the scheduled post time is showing correctly (so must be an issue with that plugin specifically in regards to that specific issue)

#5 follow-up: @charveyunm
5 years ago

I think I may have found our culprit
sleuthing our code I found several places where we use date_default_timezone_set('America/Denver');
commenting that out seems to have fixed some of our display issues.

#6 in reply to: ↑ 5 ; follow-up: @Otto42
5 years ago

Replying to charveyunm:

I think I may have found our culprit
sleuthing our code I found several places where we use date_default_timezone_set('America/Denver');
commenting that out seems to have fixed some of our display issues.

Yes, that would be a problem. WordPress expects the date_default_timezone_set to always be UTC. It calculates its own offsets internally. Some of this timezone code changed in 5.3, so there may be bugs here and there, but if you're changing the default timezone, then there would have been other problems even in previous versions. Maybe not the same results, but definitely problems.

Custom code should not need to change the default timezone if you use the WordPress time functions.

#7 in reply to: ↑ 6 @charveyunm
5 years ago

Replying to Otto42:

Yes, that would be a problem. WordPress expects the date_default_timezone_set to always be UTC. It calculates its own offsets internally. Some of this timezone code changed in 5.3, so there may be bugs here and there, but if you're changing the default timezone, then there would have been other problems even in previous versions. Maybe not the same results, but definitely problems.

Custom code should not need to change the default timezone if you use the WordPress time functions.

Thanks, yep - so far I have not run into additional issues (even with ACF PRO and classic editor) after removing all instances of setting that default time zone manually.

#8 @Rarst
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.