date_create_immutable

create a new DateTimeImmutable object

Description

DateTimeImmutablefalse date_create_immutable(string $datetime = "now", DateTimeZonenull $timezone = null)

This is the procedural version of DateTimeImmutable::__construct.

Unlike the DateTimeImmutable constructor, it will return false instead of an exception if the passed in datetime string is invalid.

Return Values

Returns a new DateTimeImmutable instance or false on failure

See Also

  • DateTimeImmutable::createFromFormat