Hi there,
You can use the generate_post_date_output
filter for this if you want to process things server side.
How do you want the date to behave? Do you want to display only the modified date in place of the post date its available?
If so, try this PHP snippet:
function db_modified_time_stamp( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time> ';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">Updated on: %4$s</time> ' . $time_string;
}
// Check modified date is newer thant published
$updated_time = get_the_modified_time( 'U' );
$published_time = get_the_time( 'U' ) + 86400;
// If modified date exists then output both time strings with modified date
if ( $updated_time > $published_time ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished" style="display: none;">Published on: %2$s</time>
<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified" style="display:inline;">Updated on: %4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date( 'F j, Y' ) ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date( 'F j, Y' ) )
);
return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}
add_filter( 'generate_post_date_output', db_modified_time_stamp, 20, 2);