Show the “last updated” date.
Paste the following code snippet into your child theme’s functions.php file:
function et_last_modified_date_blog( $the_date ) {
if ( 'post' === get_post_type() && !is_admin() ) {
$the_time = get_post_time( 'His' );
$the_modified = get_post_modified_time( 'His' );
$last_modified = sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );
return $date;
}
return $the_date;
}
add_filter( 'get_the_date', 'et_last_modified_date_blog' );
add_filter( 'get_the_time', 'et_last_modified_date_blog' );Code language: PHP (php)
Show the publish date and the last updated
function et_last_modified_date_blog( $the_date ) {
if ( 'post' === get_post_type() && !is_admin() ) {
$the_time = get_post_time( 'His' );
$the_modified = get_post_modified_time( 'His' );
$last_modified = sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );
return $date;
}
return $the_date;
}
add_filter( 'get_the_date', 'et_last_modified_date_blog' );
add_filter( 'get_the_time', 'et_last_modified_date_blog' );Code language: PHP (php)