Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#46609 new defect (bug)

Incorrect posts date on saving scheduled posts draft

Reported by: Marlimant Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1
Component: Date/Time Keywords:
Focuses: Cc:


When a scheduled post is saved, the created post date is keept, instead of the scheduled date the user wanted to program. So, when the user make a preview of the post, the date showed is incorrect, because not correspond to the scheduled post date but to the present date.
The date is corrected only when the post is programmed. I think the date of the post must be changed when the post was saved as a draft too.
Best regards,

Change History (7)

#1 @Rarst
2 years ago

  • Keywords reporter-feedback added; scheduled posts save draft removed

Could you please provide a more specific example of what date are you scheduling and where do you see the unexpected output?

#2 @Marlimant
2 years ago

Yes. For example:

  • I write a new post.
  • I set the date of that post to 3 days later.
  • Then I "Save" the post (not program it).
  • Finally I make a preview of the saved post, and the front page not show the 3 days later post date. The date showed is today post, and I beleve it is incorrect. The date showed must be that I previously established to 3 days later.

#3 @Rarst
2 years ago

I am not sure the preview is meant to be 100% accurate representation of how site will look when draft is published. I think it's mostly for checking post content.

Do you know what code exactly in theme is responsible for output you think should be corrected?

#4 @Marlimant
2 years ago

Well, the preview name is clear "pre-view", and the date is an important part of the post content, especially in a newspaper page, for example. In my case, I need to print a PDF version of the post before it be published, to then, I need to put a link to the user, who will can download the print version of the file later, when the post was published.

In that case, the saved preview version must show the established date to the post (for example, 20 minutes or 2 days forward), and not the date when the post was saved, which is irrelevant.

The date code of my page is (my page is in spanish)

<?php the_time('j \d\e\ F \d\e\ Y \|\ G:i a'); ?>

but the same occur with a native theme using:


I don't know if that codes was the culprits. I only have tested that codes with the same results. I wrote here just to see if you find the solution.

#5 @Rarst
2 years ago

  • Keywords reporter-feedback removed

I've looked into this and I think you are correct about this being broken, there is an issue with saving drafts specifically.

If post is scheduled, the preview date is correct. However when draft, with explicit scheduled date, is saved/previewed it's not.

The underlying reason seems to be that wp_update_post() will explicitly strip a date from draft unless edit_date flag is set in post data. I am not sure what the legacy behavior was, but for the current Gutenberg/REST API approach that flag is not being set on draft save.

I am guessing this is not intended behavior, but I am not familiar with Gutenberg enough to say for sure / look through front–end logic.

#6 @Marlimant
2 years ago

Thanks for the answer.
So, we find something to fix (may be). That's a good thing I think.
What would be the next steps to leave this concern to the support team?
I need to keep this thread open until I find out that someone was fixed the problem the future or I can mark it as resolved?

Last edited 2 years ago by Marlimant (previous) (diff)

#7 @Rarst
2 years ago

This should stay open until someone with relevant expertise takes a look.

Note: See TracTickets for help on using tickets.