php - Displaying text if post was within 5 hours -


currently have following string.

$timeago = human_time_diff( get_the_time('u'), current_time('timestamp') ); print $timeago; 

this returns results looks this.

1 min, 1 hour, 1 week, 1 month, , 1 year.

i trying figure out how can make work using if statement detect if post has been posted within past 5 hours, , if has make echo "new" if not, don't echo anything.

edit: tried following no success... getting confused on how make check hours portion number portion guess.

$timeago = human_time_diff( get_the_time('u'), current_time('timestamp') ); print $timeago; if( $timeago >= 0 && $timeago <= 5 ) {     print 'new'; } 

you have manually below:

$from = current_time('timestamp') - 1000000; $to = current_time('timestamp'); $diff = (int) abs($to - $from); $hours = round($diff / hour_in_seconds); if ($hours <= 1)     $hours = 1; echo $hours; //op = 278 (278 hours) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -