-
-
Save erictherobot/9e84758b6f8ad5ec6ecf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$last_modified = human_time_diff( the_modified_date('U','','', false), current_time('timestamp') ); | |
$number_of_x = preg_replace('/[^0-9]*/', '', $last_modified); | |
if ( strpos( $last_modified, 'min' ) || strpos( $last_modified, 'hour' ) || strpos($last_modified, 'sec' ) ) { | |
$wiki_date = $last_modified; | |
} elseif ( $number_of_x > 365 ) { | |
$wiki_date = __( 'a long time' ); | |
} elseif ( $number_of_x >= 180 ) { | |
$wiki_date = __( 'less than a year' ); | |
} elseif ( $number_of_x >= 60 ) { | |
$wiki_date = __( 'a couple months' ); | |
} elseif ( $number_of_x >= 30 ) { | |
$wiki_date = __( 'a month' ); | |
} elseif ( $number_of_x >= 14 ) { | |
$wiki_date = __( 'a couple weeks' ); | |
} elseif ( $number_of_x >= 7 ) { | |
$wiki_date = __( 'a week' ); | |
} elseif ( ( $number_of_x <= 3 ) && ( $number_of_x > 1 ) ) { | |
$wiki_date = __( 'a couple days' ); | |
} else { | |
$wiki_date = human_time_diff( the_modified_date('U','','', false), current_time('timestamp') ); | |
} ?> | |
<?php echo sprintf( __( 'Last updated %s ago' ), $wiki_date ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment