时间: 2020-12-3|tag: 22次围观|0 条评论

<?php
//使用date_default_timezone_set()函数来设置时区
date_default_timezone_set("PRC");

//time()函数获取当前unix时间戳
echo time();
echo "<br>";


//将UNIX时间戳格式化成文本日期时间格式

echo date("Y-m-d H:i:s");
echo "<br>";
echo date("Y/m/d H:i:s");
echo "<br>";
$t=time()+7*24*60*60;
echo date("Y年m月d日 H:i:s",$t);
echo "<br>";

//mktime()函数给定了指定日期的UNIX时间戳
$t=mktime(22,00,00,03,23,1990);
$dtime=time();
echo ($dtime-$t)/60/60/24/365;
echo "<br>";

//strtotime()函数用于将任何英文文本的日期时间转换为时间戳
echo strtotime("now");
echo "<br>";
echo strtotime("+1 day");
echo "<br>";

//microtime()返回当前 Unix 时间戳和微秒数
$start=microtime(true);
for($i=0;$i<1000000;$i++){

}
$end=microtime(true);
$usetime=$end-$start;
echo $usetime;
?>

原文链接:https://blog.csdn.net/living_ren/article/details/76222697

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《PHP中的时间日期函数
   

还没有人抢沙发呢~