Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- function get_the_clock
- Formatted the Date and Time
- @author Van Lauren Laffressia
- */
- function get_the_clock() {
- global $post;
- setlocale( LC_TIME, "fr_CA" );
- $date = get_post_time('G', true, $post);
- static $clock = 86400;
- if( !is_numeric( $date ) ) {
- $time_chunks = explode( ':', str_replace( ' ', ':', $date ) );
- $date_chunks = explode( '-', str_replace( ' ', '-', $date ) );
- $date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
- }
- $current_time = current_time( 'mysql', $gmt );
- $newer_date = ( !$newer_date ) ? strtotime( $current_time ) : $newer_date;
- // Difference in seconds
- $since = $newer_date - $date;
- // Something went wrong with date calculation and we ended up with a negative date.
- if( 0 > $since )
- return __( 'sometime', 'lexpress' );
- else {
- //Within 24 hours
- if( $since < $clock )
- return __( 'Aujourd\'hui', 'lexpress' );
- //Within 48 hours
- elseif( $since < $clock * 2 )
- return __( 'Hier', 'lexpress' );
- //Mercredi
- elseif( $since < $clock * 3 )
- return strftime( "%A", $clock );
- //Jeudi
- elseif( $since < $clock * 4 )
- return strftime( "%A", $clock );
- //Vendredi
- elseif( $since < $clock * 5 )
- return strftime( "%A", $clock );
- //Samedi
- elseif( $since < $clock * 6 )
- return strftime( "%A", $clock );
- //Dimanche
- elseif( $since < $clock * 7 )
- return strftime( "%A", $clock );
- else
- return get_the_date();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement