mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-16 06:21:28 +01:00
FIX dol_print_date with param gmt when server is not UTC.
This commit is contained in:
@@ -3887,22 +3887,27 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
|
||||
} else {
|
||||
// Date is a timestamps
|
||||
if ($time < 100000000000) { // Protection against bad date values
|
||||
$timetouse = $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
||||
|
||||
$dtts = new DateTime();
|
||||
if ($to_gmt) {
|
||||
$tzo = new DateTimeZone('UTC'); // when to_gmt is true, base for offsettz and offsetdst (so timetouse) is UTC
|
||||
$dtts->setTimezone($tzo); // important: must be before the setTimestamp
|
||||
$dtts->setTimestamp((int) $time);
|
||||
} else {
|
||||
$timetouse = (int) $time + $offsettz + $offsetdst; // TODO We could be able to disable use of offsettz and offsetdst to use only offsettzstring.
|
||||
|
||||
$tzo = new DateTimeZone(date_default_timezone_get()); // when to_gmt is false, base for offsettz and offsetdst (so timetouse) is PHP server
|
||||
$dtts->setTimestamp($timetouse); // TODO May be we can invert setTimestamp and setTimezone
|
||||
$dtts->setTimezone($tzo);
|
||||
}
|
||||
$dtts = new DateTime();
|
||||
$dtts->setTimestamp($timetouse);
|
||||
$dtts->setTimezone($tzo);
|
||||
|
||||
$newformat = str_replace(
|
||||
array('%Y', '%y', '%m', '%d', '%H', '%I', '%M', '%S', '%p', '%w', 'T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
||||
array('Y', 'y', 'm', 'd', 'H', 'h', 'i', 's', 'A', 'w', '__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
||||
$format
|
||||
);
|
||||
|
||||
$ret = $dtts->format($newformat);
|
||||
//var_dump($timetouse, $offsettz, $offsetdst, $tzo, $newformat, $ret);
|
||||
$ret = str_replace(
|
||||
array('__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
|
||||
array('T', 'Z', '__a__', '__A__', '__b__', '__B__'),
|
||||
|
||||
Reference in New Issue
Block a user