(PHP 5 >= 5.3.0, PHP 7, PHP 8)
DateTime::setTimestamp -- date_timestamp_set — Sets the date and time based on an Unix timestamp
Stile orientato agli oggetti
Stile procedurale
Sets the date and time based on an Unix timestamp.
Like DateTimeImmutable::setTimestamp() but works with DateTime.
The procedural version takes the DateTime object as its first argument.
oggettoSolo per lo stile procedurale: Un oggetto DateTime restituito da date_create(). La funzione modifica questo oggetto.
timestamp
Unix timestamp representing the date.
Setting timestamps outside the range of int is possible by using
DateTimeImmutable::modify() with the @ format.
Returns the modified DateTime object for method chaining.
Throws a DateObjectError if the object has not been correctly initialized, for example when the constructor of a child class does not call the parent constructor.
| Versione | Descrizione |
|---|---|
| 8.3.0 | A DateObjectError is now thrown if the object has not been correctly initialized; previously, an Error was thrown. |