/** * Get a new instance but with the specified second. * * @param int $second The second to use * * @return static */ public function withSeconds($second) { $second = (int) $second; $date = DateTime::mktime($this->numeric("G"), $this->numeric("i"), $second, $this->numeric("n"), $this->numeric("j"), $this->numeric("Y")); if ($date->numeric("s") !== $second) { throw new \RunetimeException("Unable to change the second of " . $this->string("Y-m-d H:i:s") . "to {$second}"); } return $date; }