[PHP日期时间函数]⑤--microtime()、getdate()、gettimeofday()、checkdate()

[PHP日期时间函数]⑤--microtime()、getdate()、gettimeofday()、checkdate()_第1张图片
Paste_Image.png
[PHP日期时间函数]⑤--microtime()、getdate()、gettimeofday()、checkdate()_第2张图片
Paste_Image.png

microtime()

echo microtime() . "
";//0.52176800 1503372062 //保留浮点数 echo microtime(true) . "
";//1503372110.551 $start = microtime(true); for ($i = 0; $i <= 1000000; $i++) { $arr[] = $i; } $end = microtime(true); echo '程序执行时间为:' . round($end - $start, 4);//程序执行时间为:0.2268
Paste_Image.png

getdate()

得到日期时间相关信息

gettimeofday()

得到当前的日期信息

checkdate()

验证日期的合法性

 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


?>
[PHP日期时间函数]⑤--microtime()、getdate()、gettimeofday()、checkdate()_第3张图片
Paste_Image.png

你可能感兴趣的:([PHP日期时间函数]⑤--microtime()、getdate()、gettimeofday()、checkdate())