lib/Orkestra/Common/Type/DateTime.php
public static function createFromFormat($format, $time, $timezone = null)
    {
        if (null === $timezone) {
            $timezone = self::getServerTimezone();
        }

        if (null === $timezone) {
            // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)
            $parent = parent::createFromFormat($format, $time);
        } else {
            $parent = parent::createFromFormat($format, $time, $timezone);
        }

        if (empty($parent)) {
            throw new TypeException('Could not create DateTime from the given format');
        }

        $datetime = new self('@' . $parent->getTimestamp());
        if (null !== $timezone) {
            $datetime->setTimezone($timezone);
        }

        return $datetime;
    }
public static function createFromFormat($format, $time, $timezone = null)
    {
        if (null === $timezone) {
            $timezone = self::getServerTimezone();
        }

        if (null === $timezone) {
            // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)
            $parent = parent::createFromFormat($format, $time);
        } else {
            $parent = parent::createFromFormat($format, $time, $timezone);
        }

        if (empty($parent)) {
            throw new TypeException('Could not create DateTime from the given format');
        }

        $datetime = new self('@' . $parent->getTimestamp());
        if (null !== $timezone) {
            $datetime->setTimezone($timezone);
        }

        return $datetime;
    }
public static function createFromFormat ( $ format , $ time , $ timezone = null ) { if ( null === $ timezone ) { $ timezone = self :: getServerTimezone ( ) ; } if ( null === $ timezone ) { // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt) $ parent = parent :: createFromFormat ( $ format , $ time ) ; } else { $ parent = parent :: createFromFormat ( $ format , $ time , $ timezone ) ; } if ( empty ( $ parent ) ) { throw new TypeException ( 'Could not create DateTime from the given format' ) ; } $ datetime = new self ( '@' . $ parent -> getTimestamp ( ) ) ; if ( null !== $ timezone ) { $ datetime -> setTimezone ( $ timezone ) ; } return $ datetime ; }
Create From Format

@param string             $format
@param string             $time
@param \DateTimeZone|null $timezone

@throws \Orkestra\Common\Exception\TypeException
@return \Orkestra\Common\Type\DateTime
Create From Format