PHP时间戳的问题几个小示例
<?php
header("Content-type:text/html;charset=utf-8");
//设置北京时间为默认时区
date_default_timezone_set('PRC');
//输出当前时间
echo date("Y-m-d H:i:s",time()); //2018-01-30 10:30:32
//获得当日凌晨的时间戳
$today = strtotime(date("Y-m-d"),time());
echo '<br>';
echo $today; //1470844800
echo '<br>';
//验证当日凌晨的时间戳是否正确
echo date("Y-m-d H:i:s",$today); //2016-08-11 00:00:00
echo '<br>';
//当天的24点时间戳
$end = $today+606024;
//验证当天的24点时间戳是否正确
echo date("Y-m-d H:i:s", $end); //2018-01-30 00:00:00
echo '<br>';
//获得指定时间的零点的时间戳
$time = strtotime('2018-01-30');
echo '<br>';
echo $time; //1401984000
echo '<br>';
//验证是否是指定时间的时间戳
echo date("Y-m-d H:i:s",$time); //2018-01-30 00:00:00
?>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。