Home >Backend Development >PHP Tutorial >facebook timeline timeline development in php just now, 5 minutes ago, yesterday 10:23, etc.
In fact, there is no technical content in this, of course, just paste the code directly, no nonsense,
But it is still quite useful in development, such as forum posts, scarves, etc., there are related applications
Copy the code The code is as follows:
function tranTime($time) {
$rtime = date("m-d H:i",$time);
$htime = date("H:i",$time);
$time = time() - $ time;
if ($time < 60) {
$str = 'just';
}
elseif ($time < 60 * 60) {
$min = floor($time/60);
$str = $min.'minutes ago';
}
elseif ($time < 60 * 60 * 24) {
$h = floor($time/(60*60));
$str = $h.'hours ago '.$htime;
}
elseif ($time < 60 * 60 * 24 * 3) {
$d = floor($time/(60*60*24));
if($d==1)
$str = 'yesterday'.$rtime;
else
$str = 'the day before yesterday'.$rtime;
}
else {
$str = $rtime;
}
return $str;
}
Copy the code The code is as follows:
$times="1286861696 ";
echo tranTime($times);
The above introduces the timeline development in facebook timeline in php just now, 5 minutes ago, yesterday 10:23, etc., including the content of facebook timeline, I hope it will be helpful to friends who are interested in PHP tutorials.