Return to Snippet

Revision: 14194
at May 22, 2009 21:40 by kawikak


Initial Code
/*
	Display the date in a friendly manner
 */
function subtleDate ($time, $day_limit = 5, $long_format = 'M j')
{
	$_DAY = 60*60*24;
	$diff = mktime() - strtotime($time);
	
	switch ($diff)
	{
		case ($diff < $_DAY): return 'Today';
		case ($diff < $_DAY*2): return 'Yesterday';
		case (floor($diff/$_DAY) < $day_limit): return floor(($diff/$_DAY)) . ' days ago';
		default: return date($long_format, strtotime($time));
		
	}
}

Initial URL
http://kawika.org

Initial Description

                                

Initial Title
Friendly date display

Initial Tags
php, date

Initial Language
PHP