Last active
June 5, 2019 13:33
-
-
Save dnshulga/01d102e76a9860368e6145bb02a44285 to your computer and use it in GitHub Desktop.
Output of ".. hours ago". If more than 24 hours (1 day) - prints the date in common format
This file contains 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 | |
$time_diff = human_time_diff( get_the_date('U'), current_time('timestamp') ); | |
if( preg_match('~day|month|year~iu', $time_diff ) ) | |
$date = get_the_date('M d'); | |
else | |
$date = $time_diff.' '.__('ago', 'project-locatization-name'); | |
?> | |
<p><?php echo $date ?></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment