----- 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 <?php
11 $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*8
16 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>
时间: 2024-12-28 17:41:20