Skip to content

Commit 3216899

Browse files
pierlonwestonruter
authored andcommitted
Use current timestamp if post does not have a date (#5450)
1 parent b634261 commit 3216899

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

includes/templates/class-amp-post-template.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,13 @@ private function build_post_data() {
302302
* @return int Post publish UTC timestamp.
303303
*/
304304
private function build_post_publish_timestamp() {
305-
$format = 'U';
306-
$timestamp = (int) get_post_time( $format, true, $this->post, true );
305+
$format = 'U';
306+
307+
if ( empty( $this->post->post_date_gmt ) || '0000-00-00 00:00:00' === $this->post->post_date_gmt ) {
308+
$timestamp = time();
309+
} else {
310+
$timestamp = (int) get_post_time( $format, true, $this->post, true );
311+
}
307312

308313
/** This filter is documented in wp-includes/general-template.php. */
309314
$filtered_timestamp = apply_filters( 'get_the_date', $timestamp, $format, $this->post );

0 commit comments

Comments
 (0)