public static function parse($date, $referenceTz = null)
    {
        if ('P' === $date[0] || ('-' === $date[0] && 'P' === $date[1])) {
            return self::parseDuration($date);
        } elseif (8 === strlen($date)) {
            return self::parseDate($date, $referenceTz);
        } else {
            return self::parseDateTime($date, $referenceTz);
        }
    }
public static function parse($date, $referenceTz = null)
    {
        if ('P' === $date[0] || ('-' === $date[0] && 'P' === $date[1])) {
            return self::parseDuration($date);
        } elseif (8 === strlen($date)) {
            return self::parseDate($date, $referenceTz);
        } else {
            return self::parseDateTime($date, $referenceTz);
        }
    }
public static function parse ( $ date , $ referenceTz = null ) { if ( 'P' === $ date [ 0 ] || ( '-' === $ date [ 0 ] && 'P' === $ date [ 1 ] ) ) { return self :: parseDuration ( $ date ) ; } elseif ( 8 === strlen ( $ date ) ) { return self :: parseDate ( $ date , $ referenceTz ) ; } else { return self :: parseDateTime ( $ date , $ referenceTz ) ; } }
Parses either a Date or DateTime, or Duration value.

@param string              $date
@param DateTimeZone|string $referenceTz

@return DateTimeImmutable|DateInterval
Parses either a Date or DateTime or Duration value .