1. //传入时间戳 显示时间格式
    2. public function sec2Time($time)
    3. {
    4. if(is_numeric($time)){
    5. $value = array(
    6. "years" => 0, "days" => 0, "hours" => 0,
    7. "minutes" => 0, "seconds" => 0,
    8. );
    9. if($time >= 31556926){
    10. $value["years"] = floor($time/31556926);
    11. $time = ($time%31556926);
    12. }
    13. if($time >= 86400){
    14. $value["days"] = floor($time/86400);
    15. $time = ($time%86400);
    16. }
    17. if($time >= 3600){
    18. $value["hours"] = floor($time/3600);
    19. $time = ($time%3600);
    20. }
    21. if($time >= 60){
    22. $value["minutes"] = floor($time/60);
    23. $time = ($time%60);
    24. }
    25. $value["seconds"] = floor($time);
    26. //return (array) $value;
    27. $t=$value["years"] ."年". $value["days"] ."天"." ". $value["hours"] ."小时". $value["minutes"] ."分".$value["seconds"]."秒";
    28. Return $t;
    29. }else{
    30. return (bool) FALSE;
    31. }
    32. }

    image.png
    显示样式;