DateTime::__construct
DateTime::__construct - Returns new DateTime object
Manual
date_create(
[string$datetime = "now"],
[DateTimeZone|null$timezone = null] ): DateTime|false
Returns 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, the current timezone will be used.
Note:
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).
Return Values
Returns a new DateTime instance. Procedural style returns false on failure.
Exceptions and Errors
Emits Exception in case of an error.
Changelog
Version | Description |
7.1.0 | From now on microseconds are filled with actual value. Not with '00000'. |