Merge pull request #18980 from OPEN-DSI/v14-fix-print-date-user-timezone
FIX user date timezone offset
This commit is contained in:
commit
308d408cd0
@ -2284,8 +2284,17 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
|||||||
} elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
|
} elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
|
||||||
$to_gmt = true;
|
$to_gmt = true;
|
||||||
$offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion'
|
$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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user