PHP: DateTime::__construct - Manual (original) (raw)
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
DateTime::__construct — Returns new DateTime object
Description
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 $timezone parameter.
timezone
A DateTimeZone object representing the timezone of $datetime.
If $timezone is omitted or [null](reserved.constants.php#constant.null), the current timezone will be used.
Note:
The
$timezoneparameter and the current timezone are ignored when the$datetimeparameter either is a UNIX timestamp (e.g.@946684800) or specifies a timezone (e.g.2010-01-28T15:00:00+02:00).
Return Values
Returns a new DateTime instance.