DateTime::__construct
Returns new DateTime object
&reftitle.description;
public DateTime::__construct
stringdatetime"now"
DateTimeZonenulltimezone&null;
Like DateTimeImmutable::__construct but works with
DateTime. Consider using the
DateTimeImmutable and features instead.
Returns a new DateTime object.
&reftitle.parameters;
datetime
&date.formats.parameter;
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.
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).
&reftitle.returnvalues;
Returns a new DateTime instance.
&reftitle.errors;
If an invalid Date/Time string is passed,
DateMalformedStringException is thrown.
Previous to PHP 8.3, this was Exception.
&reftitle.changelog;
&Version;
&Description;
8.3.0
Now throws
DateMalformedStringException if an
invalid string is passed, instead of
Exception.
&reftitle.seealso;
DateTimeImmutable::__construct