amp-wp icon indicating copy to clipboard operation
amp-wp copied to clipboard

It's always showing posted 1 seconds ago when post_date_gmt is '0000-00-00 00:00:00'

Open rana01645 opened this issue 2 years ago • 5 comments

Summary

When the post_date_gmt value is '0000-00-00 00:00:00' it's always showing posted 1 seconds ago. This fix shows the actual time for the post.

Fixes #

Checklist

  • [x] My code is tested and passes existing tests.
  • [x] My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

rana01645 avatar Mar 30 '22 09:03 rana01645

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 30 '22 09:03 CLAassistant

So this is only when a post is a draft and you're previewing, correct?

westonruter avatar Mar 30 '22 21:03 westonruter

Also, showing “1 second ago” seems fine for previewing a draft which has no date/time.

westonruter avatar Mar 30 '22 21:03 westonruter

@westonruter It's not for draft only, In my blog I'm getting this error in published post where post_date_gmt value is not added or updated. I don't know it's only my blog specific issue or not. If Wordpress always update the post_date_gmt value for published post then it's fine, otherwise these changes solved the '1 seconds ago' issue for published post without post_date_gmt value.

rana01645 avatar Apr 02 '22 07:04 rana01645

@rana01645 Why would the post_date_gmt not be getting supplied? It should be that once a post is transitioned from the draft status it should get supplied as seen in wp_insert_post():

https://github.com/WordPress/wordpress-develop/blob/671d2caa29fd1dd13aa64be610f3b503d303685b/src/wp-includes/post.php#L4181-L4197

That is, if the status doesn't have date_floating which are limited to (by default):

  • draft
  • pending
  • auto-draft

Are the posts you're seeing this issue in one of those three statuses (stati)? Are you seeing the issue for posts with the publish status?

westonruter avatar Apr 04 '22 18:04 westonruter