周大胖子 发表于 2018-8-14 22:23:52

PHP 时间戳与日期的相互转换

时间戳转日期 date()【参数需要区分大小写 否则会有 24 和 12 的不同】var_dump(date('Y-m-d H:i:s', 1502204401)); //H 24小时制 2017-08-08 23:00:01

var_dump(date('Y-m-d h:i:s', 1502204401)); //h 12小时制 2017-08-08 11:00:01
日期转时间戳 strtotime()
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
echo strtotime("20170808 23:00:01"), "\n";
?>参考地址:https://blog.csdn.net/foreverling_ling/article/details/76974627

页: [1]
查看完整版本: PHP 时间戳与日期的相互转换