function formatEventtime($eventtime) {
/* difference between current time and the event time
$eventtime in timestamp */
$timediff = time() - ((int) $eventtime);
if ($timediff < 60) {
$formattedtime='just now';
} else if ($timediff < 3600) {
$timediff = round($timediff / 60);
if ($timediff == 0)
$timediff = 1;
if ($timediff > 1)
$formattedtime=$timediff.' minutes left';
$formattedtime='a minute left';
} else if ($timediff < 86400) {
$timediff = round($timediff / 3600);
if ($timediff == 0) $timediff = 1;
if ($timediff > 1)
$formattedtime=$timediff. 'hours left';
$formattedtime='one hour left';
} else {
$timediff = round($timediff / 86400);
if ($timediff == 0) $timediff = 1;
if ($timediff > 1)
$formattedtime=$timediff. ' days left'
$formattedtime='yesterday';
}
return $formattedtime ;
}
[Monday, March 16, 2009
|
0
comments
]
Popular Posts
- Mysql query for searching a value, add weightage on the number of occurances and sort based on the weight-age
- How to add or remove WWW on URLs using htaccess.
- Elgg : The most popular open source social networking platform
- php questions
- Jquery based dynamic adding and removal of html elements.
- question regarding socket
- Tips on error 'Allowed memory size of xxx bytes exhausted'
- creating dynamic elements in HTML using Javascript.
- php questions
- Contact Me