PDA

View Full Version : x since last


blazing
09-20-2006, 05:49 AM
Hi I am having problems figuring out how to make a script that takes a time from the database and the current time and tells me when that last was, I have the 2 variables from the database setup I just need to figure out how do this:

If under a minute
a minute ago

else if
2-59 minutes

else if
1-23 hours,

if not
yesterday

any help would be great thanks

marek_mar
09-20-2006, 11:10 AM
<?php
$difference = time() - $database_time;
if($difference <= 119)
{
echo 'A minute ago.';
}
elseif($difference <= 3599)
{
echo '2 - 59 minutes';
}
elseif($difference <= 86399)
{
echo '1 - 23 hours';
}
else
{
echo 'Yesterday';
}
?>