If condition to display post published date and update date

[ad_1]

i need help,
Depending on whether a post has been edited or is created for the first time, I would like to take a different action.

My goal is to display the date of the post was created ( $published_date ) , if it was only published for the first time and was never updated or edited.

and to display the updated date if a post was updated/edited ($update_date).

but it seems my code isn’t working, Here is my code.

$published_date =  get_the_date( 'F j, Y' );
$update_date = get_the_modified_time( 'F j, Y' );
if( get_the_modified_time() == get_the_time()){
echo $published_date;
}
else{
echo $update_date;
}
}

Thank you.

  • This topic was modified 2 hours, 36 minutes ago by Jan Dembowski.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer