Code tính thời gian giữa 2 lần đăng nhập
<?php
function timeBetween($start,$end,$after=' ago',$color=1){
//both times must be in seconds
$time = $end - $start;
if($time <= 60){
if($color==1){
return '<span style="color:#009900;">Online';
}else{
return 'Online';
}
}
if(60 < $time && $time <= 3600){
return round($time/60,0).' minutes'.$after;
}
if(3600 < $time && $time <= 86400){
return round($time/3600,0).' hours'.$after;
}
if(86400 < $time && $time <= 604800){
return round($time/86400,0).' days'.$after;
}
if(604800 < $time && $time <= 2592000){
return round($time/604800,0).' weeks'.$after;
}
if(2592000 < $time && $time <= 29030400){
return round($time/2592000,0).' months'.$after;
}
if($time > 29030400){
return 'More than a year'.$after;
}
}
echo timeBetween($timedatabase,time());
?>
Nguyễn Đình Thắng @ 05:17 19/05/2017
Số lượt xem: 284
- Một số hàm thao tác với files trong PHP (19/05/17)
- Kết nối FTP bằng PHP (19/05/17)
- Thủ thuật tăng tốc website (19/05/17)
- Những câu hỏi thường gặp khi xây dựng Website (03/03/11)
- Tài liệu hướng dẫn xây dựng và thiết kế website (03/03/11)






























h


">




