PHP如何从字符串中获取时间日期
echo strtotime("now"), "<br />"; echo strtotime("10 September 2000"), "<br />"; echo strtotime("+1 day"), "<br />"; echo strtotime("+1 week"), "<br />"; echo strtotime("+1 week 2 days 4 hours 2 seconds"), "<br />"; echo strtotime("next Thursday"), "<br />"; echo strtotime("last Monday"), "<br />"; ?> 执行以上程序打印出来的结果类似:1572597225 968515200 1572683625 1573202025 1573389227 1573056000 1572192000 日期的加减运算 有时我们需要在一个日期上加减一定的时间间隔。可以使用 strtotime() 来计算一些日期时间间隔。示例如下:
<?php $start = 'last Monday'; $interval = strtotime("$start + 4 days"); echo "现在$interval 表示上周的" . date('l',$interval); ?> 执行以上程序的输出结果为:现在 $interval 表示上周的 Friday。 (编辑:ASP站长) 【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。 |
-
无相关信息