Dynamic/variable date format?
Dynamic/variable date format?
I'm having some problems figuring out what to do with date columns for a multilingual site I'm working on.
Each group of users can specify which format they want to view dates in, and this override is stored as a string (eg. "d.m.Y H:i").
Multiple datatables have to be able to be sorted by date, no matter which date format they want to use - as long as it's recognized by php date. All the datatables are generated from html tables (smarty to be specific).
Unfortunately - since I'm reworking an old site with a large user base, changing the specifications is not an option.
I know there are ways around the problem, eg. by using a hidden span - but I'd prefer to solve it "properly" if possible.
Is there any way to "tell" datatables how the dates are formatted by calling an existing function? For example something like this:
[code]
function fixDateFormat(date,format) {
// return date in a recognisable format
}
...
"aoColumnDefs": [
{ aTargets:"date", fixDateFormat("date","formatstring") }
]
[/code]
Thanks for your help,
Martin
Each group of users can specify which format they want to view dates in, and this override is stored as a string (eg. "d.m.Y H:i").
Multiple datatables have to be able to be sorted by date, no matter which date format they want to use - as long as it's recognized by php date. All the datatables are generated from html tables (smarty to be specific).
Unfortunately - since I'm reworking an old site with a large user base, changing the specifications is not an option.
I know there are ways around the problem, eg. by using a hidden span - but I'd prefer to solve it "properly" if possible.
Is there any way to "tell" datatables how the dates are formatted by calling an existing function? For example something like this:
[code]
function fixDateFormat(date,format) {
// return date in a recognisable format
}
...
"aoColumnDefs": [
{ aTargets:"date", fixDateFormat("date","formatstring") }
]
[/code]
Thanks for your help,
Martin
This discussion has been closed.