2
0
forked from Wavyzz/dolibarr

Fix: Try to add code to provide easy way to fix warning on timezone not

defined.
This commit is contained in:
Laurent Destailleur
2014-03-21 10:13:29 +01:00
parent aabd923248
commit c1411e65b7

View File

@@ -987,9 +987,9 @@ function dol_getdate($timestamp,$fast=false)
* @param int $month Month (1 to 12)
* @param int $day Day (1 to 31)
* @param int $year Year
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
* @param int $gm true or 1=Input informations are GMT values, false or 0 or 'server' = local to server TZ, 'user' = local to user TZ
* @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int Date as a timestamp, '' if error
* @return int Date as a timestamp, '' if error
* @see dol_print_date, dol_stringtotime, dol_getdate
*/
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
@@ -1015,9 +1015,21 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
if (method_exists('DateTime','getTimestamp') && empty($conf->global->MAIN_OLD_DATE))
{
if (empty($gm))
if (empty($gm) || $gm === 'server')
{
$default_timezone=@date_default_timezone_get();
// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
if (! empty($conf->global->MAIN_SERVER_TZ))
{
if ($conf->global->MAIN_SERVER_TZ != 'auto') $default_timezone=$conf->global->MAIN_SERVER_TZ;
else $default_timezone=@date_default_timezone_get();
}
else $default_timezone=@date_default_timezone_get();
$localtz = new DateTimeZone($default_timezone);
}
else if ($gm === 'user')
{
$default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]);
$localtz = new DateTimeZone($default_timezone);
}
else $localtz = new DateTimeZone('UTC');