src/View/Mustache/DateTimeHelpers.php
private function parseDateTime($time)
    {
        if (is_string($time)) {
            try {
                $time = new DateTimeImmutable($time);
            } catch (Exception $e) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid date/time value: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if ($time instanceof DateTime) {
            try {
                $time = DateTimeImmutable::createFromMutable($time);
            } catch (Exception $e) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid date/time value: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if ($time instanceof DateTimeImmutable) {
            $time = $time->setTimezone(static::$now->getTimezone());
        } else {
            throw new InvalidArgumentException('Invalid date/time for the presenter.');
        }

        return $time;
    }
private function parseDateTime($time)
    {
        if (is_string($time)) {
            try {
                $time = new DateTimeImmutable($time);
            } catch (Exception $e) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid date/time value: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if ($time instanceof DateTime) {
            try {
                $time = DateTimeImmutable::createFromMutable($time);
            } catch (Exception $e) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid date/time value: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if ($time instanceof DateTimeImmutable) {
            $time = $time->setTimezone(static::$now->getTimezone());
        } else {
            throw new InvalidArgumentException('Invalid date/time for the presenter.');
        }

        return $time;
    }
private function parseDateTime ( $ time ) { if ( is_string ( $ time ) ) { try { $ time = new DateTimeImmutable ( $ time ) ; } catch ( Exception $ e ) { throw new InvalidArgumentException ( sprintf ( 'Invalid date/time value: %s' , $ e -> getMessage ( ) ) , $ e -> getCode ( ) , $ e ) ; } } if ( $ time instanceof DateTime ) { try { $ time = DateTimeImmutable :: createFromMutable ( $ time ) ; } catch ( Exception $ e ) { throw new InvalidArgumentException ( sprintf ( 'Invalid date/time value: %s' , $ e -> getMessage ( ) ) , $ e -> getCode ( ) , $ e ) ; } } if ( $ time instanceof DateTimeImmutable ) { $ time = $ time -> setTimezone ( static :: $ now -> getTimezone ( ) ) ; } else { throw new InvalidArgumentException ( 'Invalid date/time for the presenter.' ) ; } return $ time ; }
Parse the given date and time into a DateTime object.

@param  DateTimeInterface|string $time A date/time string or a DateTime object.
@throws InvalidArgumentException If the date/time value is invalid.
@return DateTimeImmutable
Parse the given date and time into a DateTime object .