diff --git a/etemplate/inc/class.etemplate_widget_date.inc.php b/etemplate/inc/class.etemplate_widget_date.inc.php index 97fc0c7a80..4194631f30 100644 --- a/etemplate/inc/class.etemplate_widget_date.inc.php +++ b/etemplate/inc/class.etemplate_widget_date.inc.php @@ -62,17 +62,17 @@ class etemplate_widget_date extends etemplate_widget_transformer $form_name = self::form_name($cname, $this->id); $value =& self::get_array(self::$request->content, $form_name, false, true); - + if($this->type != 'date-duration' && $value) { // string with formatting letters like for php's date() method if ($this->attrs['dataformat'] && !is_numeric($value)) { - $date = date_create_from_format($this->attrs['dataformat'], $value, new DateTimeZone('UTC')); + $date = date_create_from_format($this->attrs['dataformat'], $value, egw_time::$user_timezone); } else { - $date = new egw_time((int)$value, new DateTimeZone('UTC')); + $date = new egw_time($value); } if($this->type == 'date-timeonly') { @@ -80,9 +80,8 @@ class etemplate_widget_date extends etemplate_widget_transformer } if($date) { - // Set timezone to UTC so javascript doesn't add/subtract anything - $date->setTimezone(new DateTimeZone('UTC')); - $value = $date->format(egw_time::W3C); + // postfix date-string with "Z" so javascript doesn't add/subtract anything + $value = $date->format('Y-m-d\TH:i:s\Z'); } } } @@ -109,7 +108,7 @@ class etemplate_widget_date extends etemplate_widget_transformer { $value = self::get_array($content, $form_name); $valid =& self::get_array($validated, $form_name, true); - + if ((string)$value === '' && $this->attrs['needed']) { self::set_validation_error($form_name,lang('Field must not be empty !!!')); diff --git a/etemplate/js/et2_widget_date.js b/etemplate/js/et2_widget_date.js index 273f9055d0..43a0df8884 100644 --- a/etemplate/js/et2_widget_date.js +++ b/etemplate/js/et2_widget_date.js @@ -206,7 +206,7 @@ var et2_date = et2_inputWidget.extend( * * You can use set_value to set a timestamp. * - * @return {number|null} timestamp (seconds since 1970-01-01 + * @return {number|null} timestamp (seconds since 1970-01-01) */ get_time: function() { @@ -390,7 +390,7 @@ var et2_date = et2_inputWidget.extend( // Convert to timestamp - no seconds this.date.setSeconds(0,0); - return this.date.toJSON(); + return this.date.toJSON().replace(/\.\d{3}Z$/, 'Z'); } }); et2_register_widget(et2_date, ["date", "date-time", "date-timeonly"]);