企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ <?php echo "今天是 " . date("Y/m/d") . "<br>"; //2017/04/19 echo "今天是 " . date("Y.m.d") . "<br>"; //2017.04.19 echo "今天是 " . date("Y-m-d") . "<br>"; //2017-04-19 echo "今天是 " . date("l"); //Wednesday ?> ~~~ 自动版权 ~~~ © 2010-<?php echo date("Y")?> ~~~ 下面是常用于时间的字符: ~~~ * h - 带有首位零的 12 小时小时格式 * i - 带有首位零的分钟 * s - 带有首位零的秒(00 -59) * a - 小写的午前和午后(am 或 pm) ~~~ 实例 ~~~ <?php echo "现在时间是 " . date("h:i:sa"); //当前时间是 10:07:23pm ?> ~~~ 获取给定时间中的日期部分 `date('Y-m-d',strtotime($time))` ~~~ <?php /* * 根据时间戳计算年龄 * @param $birth * @return mixed */ function howOld($birth) { list($birthYear, $birthMonth, $birthDay) = explode('-', date('Y-m-d', $birth)); list($currentYear, $currentMonth, $currentDay) = explode('-', date('Y-m-d')); $age = $currentYear - $birthYear - 1; if($currentMonth > $birthMonth || $currentMonth == $birthMonth && $currentDay >= $birthDay) $age++; return$age; } ?> ~~~