microtime()
echo microtime() . "<br/>";//0.52176800 1503372062
//保留浮点数
echo microtime(true) . "<br/>";//1503372110.551
$start = microtime(true);
for ($i = 0; $i <= 1000000; $i++) {
$arr[] = $i;
}
$end = microtime(true);
echo '程序执行时间为:' . round($end - $start, 4);//程序执行时间为:0.2268
getdate()
得到日期时间相关信息
gettimeofday()
得到当前的日期信息
checkdate()
验证日期的合法性
<?php
var_dump(getdate());
/**
* array
* 'seconds' => int 8
* 'minutes' => int 29
* 'hours' => int 3
* 'mday' => int 22
* 'wday' => int 2
* 'mon' => int 8
* 'year' => int 2017
* 'yday' => int 233
* 'weekday' => string 'Tuesday' (length=7)
* 'month' => string 'August' (length=6)
* 0 => int 1503372548
*/
var_dump(gettimeofday());
/**
* array
* 'sec' => int 1503372590
* 'usec' => int 915509
* 'minuteswest' => int 0
* 'dsttime' => int 0
*/
var_dump(checkdate(8, 12, 2016));//boolean true
var_dump(checkdate(2, 29, 2017));//boolean false
?>