PHP 8.5.0 Alpha 4 available for testing

DateTime::__construct

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

DateTime::__constructReturns new DateTime object

Descrizione

public DateTime::__construct(string $datetime = "now", ?DateTimeZone $timezone = null)

Like DateTimeImmutable::__construct() but works with DateTime. Consider using the DateTimeImmutable and features instead.

Returns a new DateTime object.

Elenco dei parametri

datetime

Una stringa data/ora. I formati validi sono descritti in Formati di Data e Tempo.

Enter "now" here to obtain the current time when using the $timezone parameter.

timezone

A DateTimeZone object representing the timezone of $datetime.

If $timezone is omitted or null, the current timezone will be used.

Nota:

The $timezone parameter and the current timezone are ignored when the $datetime parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).

Valori restituiti

Returns a new DateTime instance.

Errori/Eccezioni

If an invalid Date/Time string is passed, DateMalformedStringException is thrown. Previous to PHP 8.3, this was Exception.

Log delle modifiche

Versione Descrizione
8.3.0 Now throws DateMalformedStringException if an invalid string is passed, instead of Exception.

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy