• 实例首页
  • 自学教程
  • IT工具箱
xxxxxxxxxx
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>PHP strtotime() 函数 实例 - 自学教程(runoops.com)</title>
6
</head>
7
<body>
8
​
9
<?php
10
// 设置时区
11
date_default_timezone_set("PRC");
12
$time = strtotime("2024-09-26 17:08:08");  // 将指定日期转成时间戳 
13
// 打印当前时间  PHP_EOL 换行符,兼容不同系统
14
echo  $time, PHP_EOL;
15
​
16
echo '<br />';
17
 
18
// 更多实例
19
echo strtotime("now"), PHP_EOL;
20
echo strtotime("now"), PHP_EOL;
21
echo strtotime("10 September 2000"), PHP_EOL;
22
echo strtotime("+1 day"), PHP_EOL;
23
echo strtotime("+1 week"), PHP_EOL;
24
echo strtotime("+1 week 2 days 4 hours 2 seconds"), PHP_EOL;
25
echo strtotime("next Thursday"), PHP_EOL;
26
echo strtotime("last Monday"), PHP_EOL;
27
?>
28
​
29
</body>
30
​
31
</html>