Skip to content

Instantly share code, notes, and snippets.

@seezee
Last active May 6, 2021 06:33
Show Gist options
  • Select an option

  • Save seezee/d3370afada533310d78ac673964b244a to your computer and use it in GitHub Desktop.

Select an option

Save seezee/d3370afada533310d78ac673964b244a to your computer and use it in GitHub Desktop.
<?php
/**
* Displays the post modified date.
*
* @package There is no package.
*/
/**
* Displays the last modified date for the post with the datetime tag and the
* time zone.
*
* @parameter array $arr Allowed tags.
* @parameter string $tz The post modified time.
* @parameter string $ltz The local timezone offset.
* @parameter string $modified_time The sanitized output.
*/
function my_post_modified_date() {
$arr = array(
'time' => array(
'datetime' => array(),
),
'small' => array(),
'i' => array(),
);
$tz = get_the_modified_time( 'T' );
if ( 'CST' == $tz ) { // Standard Time. Change to match your timezone.
$ltz = '-6:00'; // Change the offset to match your timezone.
} elseif ( 'CDT' == $tz ) { // Daylight Saving Time. Change to match your timezone.
$ltz = '-5:00'; // Change the offset to match your timezone.
} else {
$ltz = '';
}
$modified_time = '<small><i>' . esc_html_e( 'Latest revision:', 'text-domain' ) . '</i> <time datetime="' . get_the_modified_time( 'Y-m-d\TG:i:s', true, null, true ) . $ltz . '">' . get_the_modified_date() . '</time></small>';
echo wp_kses( $modified_time, $arr );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment