php -- 日期时间

时间:2023-12-01 08:13:44

----- 017-datetime.php -----

 <!DOCTYPE html>
 <html>
 <head>
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
     <title>日期与时间</title>
 </head>
 <body>
 <h3>日期与时间</h3>
 <pre>
 <?php
     $start_time = substr(microtime(), 0, 10);
     echo "2014年2月28存在否?", checkdate(2, 28, 2014), "\n";
     echo "2014年2月29存在否?", checkdate(2, 29, 2014), "\n";
     echo "以数组形式返回当前时间:\n";
     print_r(@getdate());//getdate()[0] == time()36*8
     echo "现在是:", @date("Y-m-d H:i:s", @getdate()[0]+28800), "\n";
     echo "现在的格林威治时间是:", gmdate("Y-m-d H:i:s", @getdate()[0]), "\n";
     echo "当前UTC-UNIX时间戳:", time(), "\n";
     echo "今天:", @strtotime("TOday"), "\n";
     echo "明天:", @strtotime("tomorrow"), "\n";
     echo "后天:", @strtotime("tomorrow + 1days"), "\n";

     echo "当前UNIX时间戳和微秒数:";
     print_r(microtime(false));echo "\n";
     echo "当前时间戳浮点数:", microtime(true), "\n";

     date_default_timezone_set("PRC");//设置时区为东八区
     echo "东八区时间: ", date("Y-m-d H-i-s", time()), "\n";

     $end_time = substr(microtime(), 0, 10);
     echo "程序开始时间:", $start_time, "  ";
     echo "程序结束时间:", $end_time, "  \n";
     printf("程序运行了%f微秒\n", $end_time-$start_time);
 ?>
 </pre>
 </body>
 </html>

php -- 日期时间