diff --git a/system/I18n/TimeLegacy.php b/system/I18n/TimeLegacy.php index 403fced2108d..0d0ca743ee93 100644 --- a/system/I18n/TimeLegacy.php +++ b/system/I18n/TimeLegacy.php @@ -14,6 +14,8 @@ namespace CodeIgniter\I18n; use DateTime; +use Exception; +use ReturnTypeWillChange; /** * Legacy Time class. @@ -45,4 +47,21 @@ class TimeLegacy extends DateTime { use TimeTrait; + + /** + * Returns a new instance with the date set to the new timestamp. + * + * @param int $timestamp + * + * @return self + * + * @throws Exception + */ + #[ReturnTypeWillChange] + public function setTimestamp($timestamp) + { + $time = date('Y-m-d H:i:s', $timestamp); + + return self::parse($time, $this->timezone, $this->locale); + } }