amp-wp
amp-wp copied to clipboard
It's always showing posted 1 seconds ago when post_date_gmt is '0000-00-00 00:00:00'
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).
So this is only when a post is a draft and you're previewing, correct?
Also, showing “1 second ago” seems fine for previewing a draft which has no date/time.
@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 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?