public function withTimeAt(
        int $hour = null,
        int $minute = null,
        int $second = null,
        int $microsecond = null
    ) : self {
        
        $instance = clone $this;
        
        $hour        = $hour        === null ? $this->hour()        : $hour;
        $minute      = $minute      === null ? $this->minute()      : $minute;
        $second      = $second      === null ? $this->second()      : $second;
        $microsecond = $microsecond === null ? $this->microsecond() : $microsecond;
        
        $instance->date->setTime($hour, $minute, $second);
        
        // There is no API for setting the microsecond explicitly so a new instance has to be constructed.
        $format         = 'Y-m-d H:i:s';
        $value          = $instance->format($format) . '.' . substr($microsecond, 0, 6);
        $instance->date = \DateTime::createFromFormat("$format.u", $value);
        
        return $instance;
    }
public function withTimeAt(
        int $hour = null,
        int $minute = null,
        int $second = null,
        int $microsecond = null
    ) : self {
        
        $instance = clone $this;
        
        $hour        = $hour        === null ? $this->hour()        : $hour;
        $minute      = $minute      === null ? $this->minute()      : $minute;
        $second      = $second      === null ? $this->second()      : $second;
        $microsecond = $microsecond === null ? $this->microsecond() : $microsecond;
        
        $instance->date->setTime($hour, $minute, $second);
        
        // There is no API for setting the microsecond explicitly so a new instance has to be constructed.
        $format         = 'Y-m-d H:i:s';
        $value          = $instance->format($format) . '.' . substr($microsecond, 0, 6);
        $instance->date = \DateTime::createFromFormat("$format.u", $value);
        
        return $instance;
    }
public function withTimeAt ( int $ hour = null , int $ minute = null , int $ second = null , int $ microsecond = null ) : self { $ instance = clone $ this ; $ hour = $ hour === null ? $ this -> hour ( ) : $ hour ; $ minute = $ minute === null ? $ this -> minute ( ) : $ minute ; $ second = $ second === null ? $ this -> second ( ) : $ second ; $ microsecond = $ microsecond === null ? $ this -> microsecond ( ) : $ microsecond ; $ instance -> date -> setTime ( $ hour , $ minute , $ second ) ; // There is no API for setting the microsecond explicitly so a new instance has to be constructed. $ format = 'Y-m-d H:i:s' ; $ value = $ instance -> format ( $ format ) . '.' . substr ( $ microsecond , 0 , 6 ) ; $ instance -> date = \ DateTime :: createFromFormat ( "$format.u" , $ value ) ; return $ instance ; }
Returns a new instance with the time set accordingly.

Any omitted values will default to the current value.

@param int|null $hour
@param int|null $minute
@param int|null $second
@param int|null $microsecond

@return self
Returns a new instance with the time set accordingly .