准备函数:strtotime(String)
php中将日期转变为时间戳的函数。
参数:日期字符串 返回:时间戳
示例:
<?php
echo strtotime("2016-05-04 00:00:00");
?>
输出结果:1462312800
在进行日期格式转换时,先将日期转为时间戳格式,再使用date函数进行格式转换。
示例:
<?php
echo date("Y年m月d日",strtotime("2016-05-04 00:00:00"));
?>
输出结果:2016年05月04日