[PHP日期时间函数]③--time()/mktime()

[PHP日期时间函数]③--time()/mktime()_第1张图片
Paste_Image.png

time()


echo time() . "
";//1503368176 echo date("Y-m-d H:i:s") . "
";//2017-08-22 02:17:35 echo date("Y-m-d H:i:s", time()) . "
";//2017-08-22 02:17:35 echo date("Y-m-d H:i:s", time() + 24 * 3600);//2017-08-23 02:18:29
Paste_Image.png

mktime()

echo mktime(0, 0, 0, 8, 12, 2016) . "
";//1470960000 $t = mktime(0, 0, 0, 6, 1, 1990);//644198400 echo $t . "
"; echo date("Y-m-d H:i:s", $t) . "
";//1990-06-01 00:00:00 echo date("Y-m-d H:i:s", mktime(0, 0, 0, 6)) . "
";//2017-06-22 00:00:00 echo date("Y-m-d H:i:s", mktime(0)) . "
";//2017-08-22 00:27:13 $birth = mktime(0, 0, 0, 6, 1, 1990); $time = time(); echo $age = floor(($time - $birth) / (24 * 3600 * 365)) . "
";//27
[PHP日期时间函数]③--time()/mktime()_第2张图片
Paste_Image.png

你可能感兴趣的:([PHP日期时间函数]③--time()/mktime())