php 时间戳代码片断

<?php 
//当前时间戳
$today = mktime(date("H"),date("i"),date("m"),date("m"),date("d"),date("Y"));
echo "当前时间戳:" . $today ."<br/>";

echo "当前时间:" . date("Y-m-d H:i:m",$today) ."<br/>";
echo "当前时间:" . date("Y-m-d H:i:m") ."<br/>";

//计算5分钟后相差多少秒
$to = mktime(date("H"),date("i")+5,date("m"),date("m"),date("d"),date("Y"));
echo $to-$today ."<br/>";

//明天时间戳
$tomorrow = mktime(date("H"),date("i"),date("m"),date("m"),date("d")+1,date("Y"));
echo "明天当前时间:" . date("Y-m-d H:i:m",$tomorrow) ."<br/>";
?>

打印结果:
当前时间戳:1379574969
当前时间:2013-09-19 15:16:09
当前时间:2013-09-19 15:16:09
300
明天当前时间:2013-09-20 15:16:09 php


------------------------------------------------------------------------------------------------------------------
mktime(hour,minute,second,month,day,year,is_dst);
相关文章
相关标签/搜索