FIX user date timezone offset

This commit is contained in:
lvessiller 2021-10-14 16:06:22 +02:00
parent fe3e11a104
commit 5d22eeeff2

View File

@ -2284,8 +2284,17 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
} elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
$to_gmt = true;
$offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion'
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore
$offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore
if (class_exists('DateTimeZone')) {
$user_date_tz = new DateTimeZone($offsettzstring);
$user_dt = new DateTime();
$user_dt->setTimezone($user_date_tz);
$user_dt->setTimestamp($time);
$offsettz = $user_dt->getOffset();
} else {
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore
$offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore
}
}
}
}