I think I have finally found a satisfying solution. As the first poster stated, if you use sql options, you cannot sort the listing by date properly anymore. If you use a datemask on a field instead, this is ignored on add/change. So, here's the solution:
- use datemask for display
- use sql option ONLY FOR ADD/CHANGE
- use sqlw option to format locale-specific dates in the format sql needs on writing.
Here's an example (with German date format):
Kód: |
$opts['fdd']['EventDate'] = array(
'name' => 'Datum',
'select' => 'T',
'maxlen' => 10,
'sort' => true,
'options' => 'AVCL',
'default' => date("d.m.Y", strtotime("now")),
'datemask' => "d.m.Y",
'sql|AC' => "DATE_FORMAT(EventDate, '%d.%m.%Y')",
'sqlw' =>
"CONCAT_WS('-',
SUBSTRING_INDEX(" . '$val_qas' . ",'.',-1),
SUBSTRING_INDEX(SUBSTRING_INDEX(" . '$val_qas' . ",'.',2), '.', -1 ),
SUBSTRING_INDEX(" . '$val_qas' . ",'.', 1)
)"
); |
Note the "|AC" after "sql". I've only just implemented it, but it seems to work - now you have locale-specific dates on LIST/ADD/EDIT *and* correct sorting on LIST.
For other date formats, you will have to adapt the sql/datemask/sqlw options, but there are several already several posts here with examples.
Hope this helps.
|