-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It's always showing posted 1 seconds ago when post_date_gmt is '0000-00-00 00:00:00' #7014
base: develop
Are you sure you want to change the base?
Conversation
So this is only when a post is a draft and you're previewing, correct? |
@@ -26,7 +26,7 @@ | |||
sprintf( | |||
/* translators: %s: the human-readable time difference. */ | |||
__( '%s ago', 'amp' ), | |||
human_time_diff( $this->get( 'post_publish_timestamp' ), time() ) | |||
human_time_diff( $this->get( 'post_publish_timestamp' ), current_time('timestamp') ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually used to be current_time( 'timestamp' )
before, but it was changed in 39473e3. Its use was discouraged as of WordPress/WordPress-Coding-Standards#1791.
@@ -305,7 +305,7 @@ private function build_post_publish_timestamp() { | |||
$format = 'U'; | |||
|
|||
if ( empty( $this->post->post_date_gmt ) || '0000-00-00 00:00:00' === $this->post->post_date_gmt ) { | |||
$timestamp = time(); | |||
$timestamp = (int) get_the_time('U'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of time()
came from #5450. Why use get_the_time()
?
For one thing, it's not passing the $this->post
as context.
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 That is, if the status doesn't have
Are the posts you're seeing this issue in one of those three statuses (stati)? Are you seeing the issue for posts with the |
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