Cake\Chronos\MutableDate::__construct PHP Method

__construct() public method

Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance. Date instances lack time components, however due to limitations in PHP's internal Datetime object the time will always be set to 00:00:00, and the timezone will always be UTC. Normalizing the timezone allows for subtraction/addition to have deterministic results.
public __construct ( string | null $time = 'now', DateTimeZon\DateTimeZone | string | null $tz = null )
$time string | null Fixed or relative time
$tz DateTimeZon\DateTimeZone | string | null The timezone for the instance
    public function __construct($time = 'now', $tz = null)
    {
        $tz = new DateTimeZone('UTC');
        if (static::$testNow === null) {
            $time = $this->stripTime($time);
            return parent::__construct($time, $tz);
        }
        $relative = static::hasRelativeKeywords($time);
        if (!empty($time) && $time !== 'now' && !$relative) {
            $time = $this->stripTime($time);
            return parent::__construct($time, $tz);
        }
        $testInstance = clone static::getTestNow();
        if ($relative) {
            $testInstance = $testInstance;
            $testInstance = $testInstance->modify($time);
        }
        if ($tz !== $testInstance->getTimezone()) {
            $testInstance = $testInstance->setTimezone($tz === null ? date_default_timezone_get() : $tz);
        }
        $time = $testInstance->format('Y-m-d 00:00:00');
        parent::__construct($time, $tz);
    }