MDL-81894 core: system_clock should use the server timezone

This commit is contained in:
Andrew Nicols
2024-06-06 00:17:10 +08:00
parent bcd8e0d6ed
commit 2e05b9111b
3 changed files with 57 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();
}