public function fromString($input, $format = null): ?TimePoint
    {
        if ($format === null) {
            $formats = [
                'Y-m-d\TH:i:sP',        // RFC 3339
                'Y-m-d\TH:i:s.uP',      // RFC 3339 with fractional seconds
                'Y-m-d\TH:i:sO',        // ISO 8601
                'Y-m-d\TH:i:s.uO',      // ISO 8601 with fractional seconds and period
                'Y-m-d\TH:i:s,uO',      // ISO 8601 with fractional seconds and comma
                'Y-m-d\TH:iO',          // ISO 8601 with no seconds
            ];

            do {
                $datetime = DateTime::createFromFormat(array_shift($formats), $input, $this->timezone);
            } while (!$datetime instanceof DateTime && count($formats) > 0);

        } else {
            $datetime = DateTime::createFromFormat($format, $input, $this->timezone);
        }

        return ($datetime instanceof DateTime) ? $this->fromDateTime($datetime) : null;
    }
public function fromString($input, $format = null): ?TimePoint
    {
        if ($format === null) {
            $formats = [
                'Y-m-d\TH:i:sP',        // RFC 3339
                'Y-m-d\TH:i:s.uP',      // RFC 3339 with fractional seconds
                'Y-m-d\TH:i:sO',        // ISO 8601
                'Y-m-d\TH:i:s.uO',      // ISO 8601 with fractional seconds and period
                'Y-m-d\TH:i:s,uO',      // ISO 8601 with fractional seconds and comma
                'Y-m-d\TH:iO',          // ISO 8601 with no seconds
            ];

            do {
                $datetime = DateTime::createFromFormat(array_shift($formats), $input, $this->timezone);
            } while (!$datetime instanceof DateTime && count($formats) > 0);

        } else {
            $datetime = DateTime::createFromFormat($format, $input, $this->timezone);
        }

        return ($datetime instanceof DateTime) ? $this->fromDateTime($datetime) : null;
    }
public function fromString ( $ input , $ format = null ) : ? TimePoint { if ( $ format === null ) { $ formats = [ 'Y-m-d\TH:i:sP' , // RFC 3339 'Y-m-d\TH:i:s.uP' , // RFC 3339 with fractional seconds 'Y-m-d\TH:i:sO' , // ISO 8601 'Y-m-d\TH:i:s.uO' , // ISO 8601 with fractional seconds and period 'Y-m-d\TH:i:s,uO' , // ISO 8601 with fractional seconds and comma 'Y-m-d\TH:iO' , // ISO 8601 with no seconds ] ; do { $ datetime = DateTime :: createFromFormat ( array_shift ( $ formats ) , $ input , $ this -> timezone ) ; } while ( ! $ datetime instanceof DateTime && count ( $ formats ) > 0 ) ; } else { $ datetime = DateTime :: createFromFormat ( $ format , $ input , $ this -> timezone ) ; } return ( $ datetime instanceof DateTime ) ? $ this -> fromDateTime ( $ datetime ) : null ; }
Get a TimePoint from a formatted string

The format parameter should be a date() compatible string. If it is not provided this method will attempt to
parse in input with one of the following supported formats.

- UTC Implied (2015-12-10T10:10:00Z)
- RFC 3339 (2015-12-10T10:10:00+04:00, 2015-12-10T10:10:00.000000+04:00)
- ISO 8601 (2015-12-10T10:10:00+0000, 2015-12-10T10:10:00.000000+0000, 2015-12-10T10:10:00,000000+0000, etc)

Note that, if a timezone is not specified in the input string, the clock's timezone will be used.

@param string $input
@param string|null $format

@return TimePoint|null
Get a TimePoint from a formatted string