PHP通用函数,php通用_PHP教程
程序员文章站
2022-04-26 11:18:21
...
PHP通用函数,php通用
1 /** 2 * 时间轴函数, Unix 时间戳 3 * @param int $time 时间 4 */ 5 function TranTime($time) { 6 //$time = strtotime($time); 7 $nowTime = time (); 8 $message = ''; 9 //一年前 10 if (idate ( 'Y', $nowTime ) != idate ( 'Y', $time )) { 11 $message = date ( 'Y年m月d日', $time ); 12 } 13 else { 14 //同一年 15 $days = idate ( 'z', $nowTime ) - idate ( 'z', $time ); 16 switch(true){ 17 //一天内 18 case (0 == $days): 19 $seconds = $nowTime - $time; 20 //一小时内 21 if ($seconds ) {