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.
- Pattern Matching in mysql
- How to create a plugin in elgg.
- php questions
- How to find out the Mysql storage engine type of a table.
- Running a perl script from PHP
- function to check whether the year given is a leap year or not
- Share your knowledge
- Elgg : The most popular open source social networking platform
0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.