time() gives the timestamp of Greenwich Mean Time (GMT) which is defined as the official time for the whole earth. You get the local time by adding the time zone offset to this timestamp.
(PHP 4, PHP 5, PHP 7, PHP 8)
time — 返回当前的 Unix 时间戳
返回自从 Unix 纪元(格林威治时间 1970 年 1 月 1 日 00:00:00)到当前时间的秒数。
注意:
Unix 时间戳不包含任何有关本地时区的信息。建议使用 DateTimeImmutable 类来处理日期和时间信息, 以避免 Unix 时间戳带来的陷阱。
此函数没有参数。
返回当前时间戳。
示例 #1 time() 例子
<?php
echo 'Now: '. time();
?>
以上例程的输出类似于:
Now: 1660338149
在 $_SERVER['REQUEST_TIME'] 中保存了发起该请求时刻的时间戳。
time() gives the timestamp of Greenwich Mean Time (GMT) which is defined as the official time for the whole earth. You get the local time by adding the time zone offset to this timestamp.