Display text “Today” if posted today.
-
hey!
I have a problem. I have this code to get the text “Today” to show up if the post is posted the same day. The problem is, that it displays the text today for posts that were posted less than 24 hours ago, not the same date. So how can I get this to work. I want “today” to show up if the post is posted on the same date as today.
<?php
$days_old = (current_time(timestamp) – get_the_time(‘U’) – (get_settings(‘gmt_offset’) *3600 ) ) / (60*60*24);
if ($days_old <=1) {
echo “<img src=’Today!’>”;
} elseif ($days_old > 1 & $days_old <= 2) {
echo ‘Yesterday!’;
} else {
the_time(‘F jS, Y”);
}
?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Display text “Today” if posted today.’ is closed to new replies.