diff --git a/include/class.format.php b/include/class.format.php index a2d72340dcf02e3cba45990e4e455ab8146604e3..d3d9d7ae9ae68e7994e302fc70be0d079f6cae35 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -667,20 +667,20 @@ class Format { '%x', $timezone ?: $cfg->getTimezone(), $user); } - function datetime($timestamp, $fromDb=true, $timezone=false, $user=false) { + function datetime($timestamp, $fromDb=true, $format=false, $timezone=false, $user=false) { global $cfg; return self::__formatDate($timestamp, - $cfg->getDateTimeFormat(), $fromDb, + $format ?: $cfg->getDateTimeFormat(), $fromDb, IDF_SHORT, IDF_SHORT, '%x %X', $timezone ?: $cfg->getTimezone(), $user); } - function daydatetime($timestamp, $fromDb=true, $timezone=false, $user=false) { + function daydatetime($timestamp, $fromDb=true, $format=false, $timezone=false, $user=false) { global $cfg; return self::__formatDate($timestamp, - $cfg->getDayDateTimeFormat(), $fromDb, + $format ?: $cfg->getDayDateTimeFormat(), $fromDb, IDF_FULL, IDF_SHORT, '%x %X', $timezone ?: $cfg->getTimezone(), $user); } diff --git a/include/class.forms.php b/include/class.forms.php index 980f67c56ea9b991e67de2cc7c9cfaf5afb3539b..d87d9501cfbc1985ae8a820b188d26f5464ed570 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2028,7 +2028,7 @@ class DatetimeField extends FormField { function to_php($value) { - if (strtotime($value) <= 0) + if (!is_numeric($value) && strtotime($value) <= 0) return 0; return $value; @@ -2041,8 +2041,9 @@ class DatetimeField extends FormField { return ''; $config = $this->getConfiguration(); + $format = $config['format'] ?: false; if ($config['gmt']) - return $this->format((int) $datetime->format('U')); + return $this->format((int) $datetime->format('U'), $format); // Force timezone if field has one. if ($config['timezone']) { @@ -2051,10 +2052,10 @@ class DatetimeField extends FormField { } $value = $this->format($datetime->format('U'), - $datetime->getTimezone()->getName()); - + $datetime->getTimezone()->getName(), + $format); // No need to show timezone - if (!$config['time']) + if (!$config['time'] || $format) return $value; // Display is NOT timezone aware show entry's timezone. @@ -2068,16 +2069,16 @@ class DatetimeField extends FormField { return ($timestamp > 0) ? $timestamp : ''; } - function format($timestamp, $timezone=false) { + function format($timestamp, $timezone=false, $format=false) { if (!$timestamp || $timestamp <= 0) return ''; $config = $this->getConfiguration(); if ($config['time']) - $formatted = Format::datetime($timestamp, false, $timezone); + $formatted = Format::datetime($timestamp, false, $format, $timezone); else - $formatted = Format::date($timestamp, false, false, $timezone); + $formatted = Format::date($timestamp, false, $format, $timezone); return $formatted; } diff --git a/include/class.ticket.php b/include/class.ticket.php index ede3112f149acde3ba2a6a781d07929cdde5ac70..8174989cbe525f5250b1bd246298afeb5088bbb6 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2113,27 +2113,39 @@ implements RestrictedAccess, Threadable, Searchable { )), 'created' => new DatetimeField(array( 'label' => __('Create Date'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'duedate' => new DatetimeField(array( 'label' => __('Due Date'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'est_duedate' => new DatetimeField(array( 'label' => __('SLA Due Date'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'reopened' => new DatetimeField(array( 'label' => __('Reopen Date'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'closed' => new DatetimeField(array( 'label' => __('Close Date'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'lastupdate' => new DatetimeField(array( 'label' => __('Last Update'), - 'configuration' => array('fromdb' => true), + 'configuration' => array( + 'fromdb' => true, 'time' => true, + 'format' => 'y-MM-dd HH:mm:ss'), )), 'assignee' => new AssigneeChoiceField(array( 'label' => __('Assignee'),