src/Services/DateTime.php
public static function createFromParts(array $parts, $timezone = null)
    {
        $year   = isset($parts[0]) ? $parts[0] : date('Y');
        $month  = isset($parts[1]) ? $parts[1] : date('m');
        $day    = isset($parts[2]) ? $parts[2] : date('d');
        $hour   = isset($parts[3]) ? $parts[3] : 0; //date('H');
        $minute = isset($parts[4]) ? $parts[4] : 0; //date('i');
        $second = isset($parts[5]) ? $parts[5] : 0; //date('s');
        $micro  = isset($parts[6]) ? $parts[6] : 0; //date('u');
        $dateTimeString = sprintf('%04s-%02s-%02s %02s:%02s:%02s.%06s', $year, $month, $day, $hour, $minute, $second, $micro);

        return new static($dateTimeString, $timezone);
    }
public static function createFromParts(array $parts, $timezone = null)
    {
        $year   = isset($parts[0]) ? $parts[0] : date('Y');
        $month  = isset($parts[1]) ? $parts[1] : date('m');
        $day    = isset($parts[2]) ? $parts[2] : date('d');
        $hour   = isset($parts[3]) ? $parts[3] : 0; //date('H');
        $minute = isset($parts[4]) ? $parts[4] : 0; //date('i');
        $second = isset($parts[5]) ? $parts[5] : 0; //date('s');
        $micro  = isset($parts[6]) ? $parts[6] : 0; //date('u');
        $dateTimeString = sprintf('%04s-%02s-%02s %02s:%02s:%02s.%06s', $year, $month, $day, $hour, $minute, $second, $micro);

        return new static($dateTimeString, $timezone);
    }
public static function createFromParts ( array $ parts , $ timezone = null ) { $ year = isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : date ( 'Y' ) ; $ month = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : date ( 'm' ) ; $ day = isset ( $ parts [ 2 ] ) ? $ parts [ 2 ] : date ( 'd' ) ; $ hour = isset ( $ parts [ 3 ] ) ? $ parts [ 3 ] : 0 ; //date('H'); $ minute = isset ( $ parts [ 4 ] ) ? $ parts [ 4 ] : 0 ; //date('i'); $ second = isset ( $ parts [ 5 ] ) ? $ parts [ 5 ] : 0 ; //date('s'); $ micro = isset ( $ parts [ 6 ] ) ? $ parts [ 6 ] : 0 ; //date('u'); $ dateTimeString = sprintf ( '%04s-%02s-%02s %02s:%02s:%02s.%06s' , $ year , $ month , $ day , $ hour , $ minute , $ second , $ micro ) ; return new static ( $ dateTimeString , $ timezone ) ; }
Create a new DateTime instance from a specific parts of date and time.

The default of any part of date (year, month or day) is today.
The default of any part of time (hour, minute, second or microsecond) is 0.

@param array $parts [$year, $month, $day, $hour, $minute, $second, $micro] All parts are optional.
@param DateTimeZone|string|null $timezone
@return static
Create a new DateTime instance from a specific parts of date and time .