Search code examples
firefoxdateyuiyui-datatable

YUI datatable and date displaying with Firefox


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


Solution

  • 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