diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 124b8dcf1dd..b1fb2d0b014 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -479,8 +479,8 @@ if (empty($reshook) && $action == 'update') $object->fetch_userassigned(); $object->oldcopy = clone $object; - $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); + $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); + $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); $object->label = GETPOST("label", "alphanohtml"); diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 48bcbab6f3e..307864fcf81 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -84,13 +84,14 @@ abstract class DoliDB implements Database * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. * Function to use to build INSERT, UPDATE or WHERE predica * - * @param int $param Date TMS to convert - * @return string Date in a string YYYY-MM-DD HH:MM:SS + * @param int $param Date TMS to convert + * @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ + * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - public function idate($param) + public function idate($param, $gm = 'tzserver') { - // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt' - return dol_print_date($param, "%Y-%m-%d %H:%M:%S", 'tzserver'); + // TODO $param should be gmt, so we should add tzouptut to 'gmt' instead of default 'tzserver' + return dol_print_date($param, "%Y-%m-%d %H:%M:%S", $gm); } /** @@ -285,12 +286,12 @@ abstract class DoliDB implements Database * 19700101020000 -> 7200 whaterver is TZ if gmt=1 * * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ + * @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ * @return int|string Date TMS or '' */ - public function jdate($string, $gm = false) + public function jdate($string, $gm = 'tzserver') { - // TODO GMT must set param gm to true by default + // TODO $string should be converted into a GMT timestamp, so param gm should be set to true by default instead of false if ($string == 0 || $string == "0000-00-00 00:00:00") return ''; $string = preg_replace('/([^0-9])/i', '', $string); $tmp = $string.'000000'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8c1765620ec..ecfb46dc589 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2183,14 +2183,14 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '') * @param int $day Day (1 to 31) * @param int $year Year * @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values - * False or 0 or 'server' = local to server TZ - * 'user' = local to user TZ + * False or 0 or 'tzserver' = local to server TZ + * 'tzuser' = local to user TZ * 'tz,TimeZone' = use specified timezone * @param int $check 0=No check on parameters (Can use day 32, etc...) * @return int|string Date as a timestamp, '' or false if error * @see dol_print_date(), dol_stringtotime(), dol_getdate() */ -function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1) +function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'tzserver', $check = 1) { global $conf; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; @@ -2211,11 +2211,11 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ if ($second < 0 || $second > 60) return ''; } - if (empty($gm) || $gm === 'server') + if (empty($gm) || ($gm === 'server' || $gm === 'tzserver')) { $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' $localtz = new DateTimeZone($default_timezone); - } elseif ($gm === 'user') + } elseif ($gm === 'user' || $gm === 'tzuser') { // We use dol_tz_string first because it is more reliable. $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin'