This issue was supposed to be fixed in 2.0.3 via this pull request: https://github.com/ampproject/amp-wp/pull/5335
What timezone is your WordPress install set to?
Do you have any get_the_date or get_post_time filters added?
The Schema.org metadata indicates the publishedDate is 2020-09-22T04:25:00+00:00. The post says “3 GODZINY TEMU” (3 hours ago). The current time at this moment is 2020-09-22T05:33:19.702Z. So indeed, it should have been 1 hour not 3.
Thread Starter
Łukasz
(@lumay)
Should I check/do something or do you fix it in the future? Thx!
Thread Starter
Łukasz
(@lumay)
<time datetime="<?php echo esc_attr( date( 'c', $this->get( 'post_publish_timestamp' ) ) ); ?>">
<?php
echo esc_html(
sprintf(
/* translators: %s: the human-readable time difference. */
__( '%s temu', 'amp' ),
human_time_diff( $this->get( 'post_publish_timestamp' ), current_time( 'timestamp' ) )
)
);
?>
</time>
-
This reply was modified 5 years, 5 months ago by
Łukasz.
I just tried to reproduce the issue by setting my timezone to Warsaw, and when I publish a post it says “X seconds ago” rather than “2 hours ago”.
Thread Starter
Łukasz
(@lumay)
OK I’ve changed code because I’ve got old code in wp-content/theme/my-theme/amp
Should I change my amp files in theme catalogue after every update?
Thread Starter
Łukasz
(@lumay)
With this code is OK:
`<time datetime=”<?php echo esc_attr( gmdate( ‘c’, $this->get( ‘post_publish_timestamp’ ) ) ); ?>”>
<?php
echo esc_html(
sprintf(
/* translators: %s: the human-readable time difference. */
__( ‘%s temu’, ‘amp’ ),
human_time_diff( $this->get( ‘post_publish_timestamp’ ), time() )
)
);
?>
</time>`
I’ve deleted timestamp from this: current_time( 'timestamp' ) and time is Ok now
-
This reply was modified 5 years, 5 months ago by
Łukasz.
Or you could just replace current_time( 'timestamp' ) with current_time( 'timestamp', true ).
The issue is that without the second parameter of true, a non-GMT/UTC timestamp value is returned.
Thread Starter
Łukasz
(@lumay)
Thank you! I’ve got translated meta-time.php in my theme folder – should I chanege every copied files from new update?
It appears you forked the meta-time.php template from before 1.5. In that release, we fixed the usage of current_time(): https://github.com/ampproject/amp-wp/commit/39473e393dba20af83136f4fef8fa4eb70db58f2
But since you forked the template, you didn’t get the update.
Generally the legacy AMP templates are not updated each new release, so you shouldn’t have to do that. But it’s not a bad idea to double-check.
In 2.0.1 we reduced one area where forked templates would need to make updates to a forked style.php stylesheet: https://github.com/ampproject/amp-wp/pull/5282
Thread Starter
Łukasz
(@lumay)
OK thx
When I replace current_time( 'timestamp' ) with current_time( 'timestamp', true ).
there is
Parse error
: syntax error, unexpected ‘;’, expecting ‘)’ in
/wp-content/themes/leaf/amp/meta-time.php
on line
18
W witrynie wystąpił błąd krytyczny.
It looks like you removed the second closing parenthesis.
You can make the whole line look like this:
human_time_diff( $this->get( 'post_publish_timestamp' ), time() )
Just copy what is shown here: https://github.com/ampproject/amp-wp/blob/c6312571e38b0b27258eacfd70cec410e9569ba0/templates/meta-time.php#L29
Thread Starter
Łukasz
(@lumay)
OK thx with current_time( 'timestamp', true ) is ok too
Thx @westonruter so much for your quick help!!!
<?php
/**
* Post date template part.
*
* @package AMP
*/
?>
<div class="amp-wp-meta amp-wp-posted-on">
<time datetime="<?php echo esc_attr( gmdate( 'c', $this->get( 'post_publish_timestamp' ) ) ); ?>">
<?php
echo esc_html(
sprintf(
/* translators: %s: the human-readable time difference. */
__( '%s ago', 'amp' ),
human_time_diff( $this->get( 'post_publish_timestamp' ), current_time( 'timestamp', true ) )
)
);
?>
</time>
</div>