標籤:style class blog c code java
----- 017-datetime.php -----
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>日期與時間</title> 6 </head> 7 <body> 8 <h3>日期與時間</h3> 9 <pre>10 <?php11 $start_time = substr(microtime(), 0, 10);12 echo "2014年2月28存在否?", checkdate(2, 28, 2014), "\n";13 echo "2014年2月29存在否?", checkdate(2, 29, 2014), "\n";14 echo "以數組形式返回目前時間:\n";15 print_r(@getdate());//getdate()[0] == time()36*816 echo "現在是:", @date("Y-m-d H:i:s", @getdate()[0]+28800), "\n";17 echo "現在的格林威治時間是:", gmdate("Y-m-d H:i:s", @getdate()[0]), "\n";18 echo "當前UTC-UNIX時間戳記:", time(), "\n";19 echo "今天:", @strtotime("TOday"), "\n";20 echo "明天:", @strtotime("tomorrow"), "\n";21 echo "後天:", @strtotime("tomorrow + 1days"), "\n";22 23 echo "當前UNIX時間戳記和微秒數:";24 print_r(microtime(false));echo "\n";25 echo "目前時間戳浮點數:", microtime(true), "\n";26 27 date_default_timezone_set("PRC");//設定時區為東八區28 echo "東八區時間: ", date("Y-m-d H-i-s", time()), "\n";29 30 $end_time = substr(microtime(), 0, 10);31 echo "程式開始時間:", $start_time, " ";32 echo "程式結束時間:", $end_time, " \n";33 printf("程式運行了%f微秒\n", $end_time-$start_time);34 ?>35 </pre>36 </body>37 </html>