如何将代码中的** * 格式化友好时间格式 * @param un改写为一个长尾词的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计218个文字,预计阅读时间需要1分钟。
plaintextgistfile1.txt +{时间戳|转换为日期} / 格式化时间友好的日期 / @param 时间戳 @return 字符串 /function 转换日期($time=NULL){ $text=''; $time=$time===NULL || $time==='' ? time() : intval($time); $t=time() - $time; /** */}
gistfile1.txt<{$rs.regtime|mdate}> /** * 格式化友好时间格式 * @param unknown $time * @return string */ function mdate($time = NULL) { $text = ''; $time = $time === NULL || $time > time() ? time() : intval($time); $t = time() - $time; //时间差 (秒) if ($t == 0) $text = '刚刚'; elseif ($t < 60) $text = $t . '秒前'; // 一分钟内 elseif ($t < 60 * 60) $text = floor($t / 60) . '分钟前'; //一小时内 elseif ($t < 60 * 60 * 24) $text = floor($t / (60 * 60)) . '小时前'; // 一天内 elseif ($t < 60 * 60 * 24 * 3) $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $t) : '前天 ' . date('H:i', $time) ; //昨天和前天 elseif ($t < 60 * 60 * 24 * 30) $text = date('m月d日 H:i', $time); //一个月内 elseif ($t < 60 * 60 * 24 * 365) $text = date('m月d日', $time); //一年内 else $text = date('Y年m月d日', $time); //一年以前 return $text; }
本文共计218个文字,预计阅读时间需要1分钟。
plaintextgistfile1.txt +{时间戳|转换为日期} / 格式化时间友好的日期 / @param 时间戳 @return 字符串 /function 转换日期($time=NULL){ $text=''; $time=$time===NULL || $time==='' ? time() : intval($time); $t=time() - $time; /** */}
gistfile1.txt<{$rs.regtime|mdate}> /** * 格式化友好时间格式 * @param unknown $time * @return string */ function mdate($time = NULL) { $text = ''; $time = $time === NULL || $time > time() ? time() : intval($time); $t = time() - $time; //时间差 (秒) if ($t == 0) $text = '刚刚'; elseif ($t < 60) $text = $t . '秒前'; // 一分钟内 elseif ($t < 60 * 60) $text = floor($t / 60) . '分钟前'; //一小时内 elseif ($t < 60 * 60 * 24) $text = floor($t / (60 * 60)) . '小时前'; // 一天内 elseif ($t < 60 * 60 * 24 * 3) $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $t) : '前天 ' . date('H:i', $time) ; //昨天和前天 elseif ($t < 60 * 60 * 24 * 30) $text = date('m月d日 H:i', $time); //一个月内 elseif ($t < 60 * 60 * 24 * 365) $text = date('m月d日', $time); //一年内 else $text = date('Y年m月d日', $time); //一年以前 return $text; }

