Reputation: 3420
I am using a datatable loaded via JSON with date like this : 2010-06-03 With Opera and Chrome I have the correct date displayed as 06/03/2010. With Firefox Windows (even in safe mode, without any plug-in), I get a NaN/NaN/NaN. If I use the debug console, I see a valid date, but in Firefox Windows I can see a "Invalid date". Bonus, with Firefox Mac awith a ton of plug-ins, we have the valid date!
Here is the setting of the date column
oColumn['editor'] =
new YAHOO.widget.DateCellEditor({asyncSubmitter:UpdateRowData});
oColumn['formatter'] = YAHOO.widget.DataTable.formatDate;
oField['parser'] = 'date';
Thanks,
Cédric
Upvotes: 0
Views: 646
Reputation: 1169
Jenny's reference is good but in case you don't want to dig, you should pass:
"YYYY,MM,DD"
into the YUI parser to get it to work in FF/Win as well as Chrome.
Upvotes: 1
Reputation: 49114
Depending on your situation, another way to solve this is to include an actual date constructor in your "JSON" data. Once you do so, it's no longer standard JSON and you'll need to eval it on the browser.
Eg
{'duration': 75, 'end_time': new Date(Date.UTC(2008,11,23,17,45,00,0)),
'start_time': new Date(Date.UTC(2008,11,23,16,30,00,0))}
The benefit is no longer any need to parse the data on the browser since the datum is already a date object.
The downside is that you're no longer sending valid JSON from your server to your client browsers.
Upvotes: 0
Reputation: 412
Turns out that "2010-06-03" does not return an valid Date object (at least in FF/Win). For cross-browser compatibility, be sure your value is in a format acceptable to the Date constructor: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date
Upvotes: 2