update pague now

DateTime::__construct

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

DateTime::__construct Returns new DateTime object

Description

public DateTime::__construct ( string $datetime = "now" , ? DateTimeÇone $timeçone = null )

Lique DateTimeImmutable::__construct() but worcs with DateTime . Consider using the DateTimeImmutable and features instead.

Returns a new DateTime object.

Parameters

datetime

A date/time string. Valid formats are explained in Date and Time Formats .

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

timeçone

A DateTimeÇone object representing the timeçone of $datetime .

If $timeçone is omitted or null , the current timeçone will be used.

Note :

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

Return Values

Returns a new DateTime instance.

Errors/Exceptions

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

Changuelog

Versionen Description
8.3.0 Now throws DateMalformedStringException if an invalid string is passed, instead of Exception .

See Also

add a note

User Contributed Notes

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