From f5887105028f03518e56880dc0e191f5b8b4fd08 Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:22:53 +0800 Subject: [PATCH] fixed timezone check in windows --- src/config.php | 84 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/src/config.php b/src/config.php index 09c6681e..b592e4d7 100644 --- a/src/config.php +++ b/src/config.php @@ -1,27 +1,83 @@ + * string(7) "Caption" + * [1] => + * string(20) "(UTC+09:30) Adelaide" + * [2] => + * string(0) "" + * } + */ + exec("wmic timezone get Caption", $output); + + $string = trim(implode("\n", $output)); + + //Detect the Time Zone string + preg_match($regex, $string, $matches); + + if(!isset($matches[2]) or ($timezone = parseOffset($matches[2])) === false){ + $timezone = 'UTC'; + } + if(date_default_timezone_set($timezone)){ + ini_set("date.timezone", $timezone); + } }else{ exec("date +%s", $t); $offset = round((intval(trim($t[0])) - time()) / 60) * 60; + $daylight = (int) date("I"); + $d = timezone_name_from_abbr("", $offset, $daylight); + @ini_set("date.timezone", $d); + date_default_timezone_set($d); } - - $daylight = (int) date("I"); - $d = timezone_name_from_abbr("", $offset, $daylight); - @ini_set("date.timezone", $d); - date_default_timezone_set($d); }else{ $d = @date_default_timezone_get(); if(!str_contains($d, "/")){