Dunstan's Time of Day code that provides a friendlier display of post
times. WP 1.2 users should use the older plugin.
Version: 1.0.1
Author: Phu Ly & Dunstan Orchard & Michael Heilemann
Author URI: http://www.ifelse.co.uk
*/
function time_of_day($content) {
//$pdate = strtotime($content);
$pdate = strtotime(str_replace("
","",$content)); //WP-Admin adds a break tag for display purposes which we have to strip out.
$hour=date('H',$pdate);
switch($hour)
{
case 0:
case 1:
case 2:
$tod = 'in the wee hours';
break;
case 3:
case 4:
case 5:
case 6:
$tod = 'terribly early in the morning';
break;
case 7:
case 8:
case 9:
$tod = 'in the early morning';
break;
case 10:
$tod = 'mid-morning';
break;
case 11:
$tod = 'just before lunchtime';
break;
case 12:
case 13:
$tod = 'around lunchtime';
break;
case 14:
$tod = 'in the early afternoon';
break;
case 15:
case 16:
$tod = 'mid-afternoon';
break;
case 17:
$tod = 'in the late afternoon';
break;
case 18:
case 19:
$tod = 'in the early evening';
break;
case 20:
case 21:
$tod = 'at around evening time';
break;
case 22:
$tod = 'in the late evening';
break;
case 23:
$tod = 'late at night';
break;
default:
$tod = '';
break;
}
return $tod;
}
add_filter('the_time','time_of_day');
?>