MDL-81894 core: system_clock should use the server timezone

This commit is contained in:
Andrew Nicols
2024-06-06 00:18:52 +08:00
parent 1291869f90
commit 253c16b64d
3 changed files with 54 additions and 1 deletions
+6 -1
View File
@@ -24,10 +24,15 @@ namespace core;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class system_clock implements clock {
#[\Override]
public function now(): \DateTimeImmutable {
return new \DateTimeImmutable();
return new \DateTimeImmutable(
datetime: "now",
timezone: \core_date::get_server_timezone_object(),
);
}
#[\Override]
public function time(): int {
return $this->now()->getTimestamp();
}