time

(PHP 4, PHP 5, PHP 7, PHP 8)

time現在の Unix タイムスタンプを返す

説明

time(): int

現在時刻を Unix エポック (1970 年 1 月 1 日 00:00:00 GMT) からの通算秒として返します。

注意:

Unixタイムスタンプは、ローカルタイムゾーンに関する情報を含んでいません。 Unixタイムスタンプに付随する落とし穴を避けつつ、 日付/時刻に関する情報を扱うために DateTimeImmutable を使うことを推奨します。

パラメータ

この関数にはパラメータはありません。

戻り値

現在のタイムスタンプを返します。

例1 time() の例

<?php
echo 'Now: '. time();
?>

上の例の出力は、 たとえば以下のようになります。

Now: 1660338149

注意

ヒント

$_SERVER['REQUEST_TIME'] によって、リクエスト開始時のタイムスタンプが取得できます。

参考

add a note

User Contributed Notes 1 note

up
-13
r at rcse dot de
4 months ago
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.
To Top