lib/Utils/DateTimeUtils.php
public static function createFromArray(array $datetime): ?DateTimeInterface
    {
        $dateAndTime = $datetime['datetime'] ?? '';
        $timeZone = $datetime['timezone'] ?? '';

        if ($dateAndTime === '' || !is_string($dateAndTime)) {
            return null;
        }

        if ($timeZone === '' || !is_string($timeZone)) {
            return null;
        }

        return new DateTimeImmutable($dateAndTime, new DateTimeZone($timeZone));
    }
public static function createFromArray(array $datetime): ?DateTimeInterface
    {
        $dateAndTime = $datetime['datetime'] ?? '';
        $timeZone = $datetime['timezone'] ?? '';

        if ($dateAndTime === '' || !is_string($dateAndTime)) {
            return null;
        }

        if ($timeZone === '' || !is_string($timeZone)) {
            return null;
        }

        return new DateTimeImmutable($dateAndTime, new DateTimeZone($timeZone));
    }
public static function createFromArray ( array $ datetime ) : ? DateTimeInterface { $ dateAndTime = $ datetime [ 'datetime' ] ?? '' ; $ timeZone = $ datetime [ 'timezone' ] ?? '' ; if ( $ dateAndTime === '' || ! is_string ( $ dateAndTime ) ) { return null ; } if ( $ timeZone === '' || ! is_string ( $ timeZone ) ) { return null ; } return new DateTimeImmutable ( $ dateAndTime , new DateTimeZone ( $ timeZone ) ) ; }
Creates a new \DateTimeImmutable instance from provided array.

The array needs to contain two keys with string values:
1) "datetime" - for date & time in one of the valid formats
2) "timezone" - a valid timezone identifier

Returns null if provided array is not of valid format.
Creates a new \ DateTimeImmutable instance from provided array .