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 GMT) からの通算秒として返します。
注意:
Unixタイムスタンプは、ローカルタイムゾーンに関する情報を含んでいません。 Unixタイムスタンプに付随する落とし穴を避けつつ、 日付/時刻に関する情報を扱うために DateTimeImmutable を使うことを推奨します。
この関数にはパラメータはありません。
現在のタイムスタンプを返します。
例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.