array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.time.php', 1 => 'time', ), 'up' => array ( 0 => 'ref.datetime.php', 1 => 'Date/Time 函数', ), 'prev' => array ( 0 => 'function.strtotime.php', 1 => 'strtotime', ), 'next' => array ( 0 => 'function.timezone-abbreviations-list.php', 1 => 'timezone_abbreviations_list', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/datetime/functions/time.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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'] 中保存了发起该请求时刻的时间戳。