PHP
function times($time,$type=""){ $show=time()-$time; $phuts=explode('.',($show/60)); $phut_time=$phuts[0]; $giay_time=$show-($phuts[0]*60); $gios=explode('.',($show/60/60)); $gio_time=$gios[0]; $phut_gios=explode('.',(($show-($gios[0]*3600))/60)); $phut_gio_time=$phut_gios[0]; $ngays=explode('.',($show/60/60/24)); $ngay_time=$ngays[0]; $date_ifs=explode('.',($show/60/60/24)); $date_if_time=$date_ifs[0]; if($show<60){ $times="Vừa xong"; }elseif($show>=60 and $show<3600){ $times="Cách đây ".$phut_time." phút ".$giay_time." giây"; }elseif($show>=3600 and $show<3600*24){ $times="Cách đây ".$gio_time." giờ ".$phut_gio_time." phút trước"; }elseif($date_if_time==1){ $times="Hôm qua, lúc ".date("H:i",$time); }else{ $times="Cách đây ".$ngay_time." ngày"; } return $times; }
chuyển sang timestamp rùi dùng =))
date("U");