Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/templates/class-amp-post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

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.

} else {
$timestamp = (int) get_post_time( $format, true, $this->post, true );
}
Expand Down
2 changes: 1 addition & 1 deletion templates/meta-time.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') )
Copy link
Member

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.

)
);
?>
Expand Down