PHP 8.3.4 Released!

DateTime::setTimestamp

date_timestamp_set

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

DateTime::setTimestamp -- date_timestamp_setUnix タイムスタンプを用いて日付と時刻を設定する

説明

オブジェクト指向型

public DateTime::setTimestamp(int $timestamp): DateTime

手続き型

date_timestamp_set(DateTime $object, int $timestamp): DateTime

Unix タイムスタンプを用いて日付と時刻を設定します。

DateTimeImmutable::setTimestamp() に似ていますが、 DateTime を使って動作します。

手続き型のバージョンは、 DateTime オブジェクトを最初の引数に取ります。

パラメータ

object

手続き型のみ: date_create() が返す DateTime オブジェクト。 この関数は、このオブジェクトを変更します。

timestamp

日付を表す Unix タイムスタンプ。 DateTimeImmutable::modify()@ フォーマットと共に使うと、 数値型の範囲外のタイムスタンプを設定できます。

戻り値

メソッドチェインに使う、変更された DateTime オブジェクトを返します。

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top