Cake\Chronos\Traits\FactoryTrait::createFromFormat PHP Method

createFromFormat() public static method

Create a ChronosInterface instance from a specific format
public static createFromFormat ( string $format, string $time, DateTimeZon\DateTimeZone | string | null $tz = null ) : static
$format string The date() compatible format string.
$time string The formatted date string to interpret.
$tz DateTimeZon\DateTimeZone | string | null The DateTimeZone object or timezone name the new instance should use.
return static
    public static function createFromFormat($format, $time, $tz = null)
    {
        if ($tz !== null) {
            $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz));
        } else {
            $dt = parent::createFromFormat($format, $time);
        }
        $errors = parent::getLastErrors();
        if ($dt == false) {
            throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors']));
        }
        $dt = static::instance($dt);
        static::$_lastErrors = $errors;
        return $dt;
    }