PHP 将发布时间修改为中文提示
程序员文章站
2024-01-25 10:34:29
...
<?php header('content-type:text/html;charset=utf-8'); function transferTime($time){ $rtime = date("m-d H:i", $time); $htime = date("H:i", $time); $time = time() - $time; if ($time < 60) { $str = '刚刚'; } elseif ($time < 60 * 60) { $min = floor($time / 60); $str = $min . '分钟前'; } elseif ($time < 60 * 60 * 24) { $h = floor($time / (60 * 60)); $str = $h . '小时前 ' . $htime; } elseif ($time < 60 * 60 * 24 * 3) { $d = floor($time / (60 * 60 * 24)); if ($d == 1) $str = '昨天 ' . $rtime; else $str = '前天 ' . $rtime; } else { $str = $rtime; } return $str; } $date = "1506505033"; echo transferTime($date);
效果图:
上一篇: 在Word2003文档中使用拆分窗口功能
下一篇: 在Word2003文档中添加页眉和页脚
推荐阅读