src/DateTime.php
public function setDateTime(...$params)
	{
		switch (count($params))
		{
			case 5:
				//	$second is optional in setTime()
			//	array_push($params, 0);		//	I don't think we need this ... array_slice should pass 2 params to setTime()!
				//	fallthrough
			case 6:
				return parent::setDate(...array_slice($params, 0, 3))->setTime(...array_slice($params, 3, 3));
			case 1:
				$param = $params[0];
				if (is_string($param))
				{
					if (preg_match('~(\d\d\d\d)-(\d\d)-(\d\d) ([012]\d):([0-5]\d):([0-5]\d)~', $param, $values) === 1) {
						return parent::setDate(...array_slice($values, 1, 3))->setTime(...array_slice($values, 4, 3));
					}
					throw new \InvalidArgumentException("Invalid DateTime format `{$param}` passed to setDateTime(); expecting `YYYY-MM-DD HH:MM:SS`");
				}
		}
		throw new \InvalidArgumentException('Invalid number or type of params for setDateTime(); requires one DateTime string or 6x params for year, month, day, hour, minute, second');
	}
public function setDateTime(...$params)
	{
		switch (count($params))
		{
			case 5:
				//	$second is optional in setTime()
			//	array_push($params, 0);		//	I don't think we need this ... array_slice should pass 2 params to setTime()!
				//	fallthrough
			case 6:
				return parent::setDate(...array_slice($params, 0, 3))->setTime(...array_slice($params, 3, 3));
			case 1:
				$param = $params[0];
				if (is_string($param))
				{
					if (preg_match('~(\d\d\d\d)-(\d\d)-(\d\d) ([012]\d):([0-5]\d):([0-5]\d)~', $param, $values) === 1) {
						return parent::setDate(...array_slice($values, 1, 3))->setTime(...array_slice($values, 4, 3));
					}
					throw new \InvalidArgumentException("Invalid DateTime format `{$param}` passed to setDateTime(); expecting `YYYY-MM-DD HH:MM:SS`");
				}
		}
		throw new \InvalidArgumentException('Invalid number or type of params for setDateTime(); requires one DateTime string or 6x params for year, month, day, hour, minute, second');
	}
public function setDateTime ( ... $ params ) { switch ( count ( $ params ) ) { case 5 : //	$second is optional in setTime()
 //	array_push($params, 0);		//	I don't think we need this ... array_slice should pass 2 params to setTime()!
 //	fallthrough
 case 6 : return parent :: setDate ( ... array_slice ( $ params , 0 , 3 ) ) -> setTime ( ... array_slice ( $ params , 3 , 3 ) ) ; case 1 : $ param = $ params [ 0 ] ; if ( is_string ( $ param ) ) { if ( preg_match ( '~(\d\d\d\d)-(\d\d)-(\d\d) ([012]\d):([0-5]\d):([0-5]\d)~' , $ param , $ values ) === 1 ) { return parent :: setDate ( ... array_slice ( $ values , 1 , 3 ) ) -> setTime ( ... array_slice ( $ values , 4 , 3 ) ) ; } throw new \ InvalidArgumentException ( "Invalid DateTime format `{$param}` passed to setDateTime(); expecting `YYYY-MM-DD HH:MM:SS`" ) ; } } throw new \ InvalidArgumentException ( 'Invalid number or type of params for setDateTime(); requires one DateTime string or 6x params for year, month, day, hour, minute, second' ) ; }
Set the date and time all together

This function also supports sending a single DateTime string in `YYYY-MM-DD HH:MM:SS` format

@param	int|string  $year     |  $datetime string
@param	int         $month
@param	int         $day
@param	int         $hour
@param	int         $minute
@param	int         $second = 0

@throws \InvalidArgumentException

@return static
Set the date and time all together