Warning!
In order to play safely and more comfortable on newest (88+) patches, please consider downloading map only from trusted sources. This site it the only official place so far, and so will be Ranked Gaming pretty soon.
In case if you want to play 88+ patches on Garena make sure you downloaded map from here and installed GarenaTotal. In case if you go on without GarenaTotal, game will crash soon due to Garena's issues.
This can be used for comments and other from of communication to tell the time ago instead of the exact time which might not be correct to some one in another time zone.
The function only uses unix time stamp like the result of time();
Technique #1
<?php
function ago($time)
{
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] 'ago' ";
}
?>
Technique #2
function _ago($tm,$rcs = 0) {
$cur_tm = time(); $dif = $cur_tm-$tm;
$pds = array('second','minute','hour','day','week','month','year','decade');
$lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600);
for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]);
$no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]);
if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm);
return $x;
}
Needs a time() value, and it will tell you how many seconds/minutes/hours/days/years/decades ago.
Prepare for Autumn sales !
PHP Custom Time Ago Function
This PHP code reads the value of the date field on form post. This value will be passed as an argument to the custom timeago() function.
In timeago() function the given date is converted into timestamp using PHP built-in strtotime(). And, this timestamp is subtracted from the current timestamp to calculate elapsed time.
The time elapsed from the given date till now is used to calculate the time ago string. The code is,
<?php $strTimeAgo = ""; if(!empty($_POST["date-field"])) { $strTimeAgo = timeago($_POST["date-field"]); } function timeago($date) { $timestamp = strtotime($date); $strTime = array("second", "minute", "hour", "day", "month", "year"); $length = array("60","60","24","30","12","10"); $currentTime = time(); if($currentTime >= $timestamp) { $diff = time()- $timestamp; for($i = 0; $diff >= $length[$i] && $i < count($length)-1; $i++) { $diff = $diff / $length[$i]; } $diff = round($diff); return $diff . " " . $strTime[$i] . "(s) ago "; } } ?>
Code leaked.
7.00 is out !