From 4f910c4a5ee471cb3c65845fb61ffd1c081b0e9b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 20 Aug 2009 11:41:13 +0000 Subject: [PATCH] "automatic convert db timestamps to unix timestamps, our db class does the reverse on writing them" --- etemplate/inc/class.date_widget.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php index 4d3105a530..2b6f9a315c 100644 --- a/etemplate/inc/class.date_widget.inc.php +++ b/etemplate/inc/class.date_widget.inc.php @@ -17,7 +17,7 @@ * Contains the following widgets: Date, Date+Time, Time, Hour, Duration * * Supported attributes: format[,options] - * format: ''=timestamp, or eg. 'Y-m-d H:i' for 2002-12-31 23:59 + * format: '' = timestamps or automatic conversation, or eg. 'Y-m-d H:i:s' for 2002-12-31 23:59:59 * options: &1 = year is int-input not selectbox, &2 = show a [Today] button, (html-UI always uses jscal and dont care for &1+&2) * &4 = 1min steps for time (default is 5min, with fallback to 1min if value is not in 5min-steps), * &8 = dont show time for readonly and type date-time if time is 0:00, @@ -107,6 +107,11 @@ class date_widget 'data_format' => $data_format, ); } + // automatic convert db timestamps to unix timestamps, our db class does the reverse on writing them + if ($value && !$data_format && !is_numeric($value) && ($v = strtotime($value))) + { + $value = $v; + } // for date-(time|hour)only widgets we distinct between between 0 and ''/null timestamps if (!$value && ($type != 'date-timeonly' && $type != 'date-houronly' || (string)$value === '')) {