View Full Version : [CLOSED-205] Dates coming as NaN on Safari only

6 Aug 2010, 2:58 PM
I have some dates that I'm posting that are being transformed from their raw JSON response to a pretty date. This works fine for Chrome but in Safari they come across as "NaN-NaN-NaN".

Here's the code for the date transform and I have them specified as type "date" in the model (also tried string):

<textarea class="x-hidden-display" id="dieinfo-dates">
<p>ES (Latest): {latestESDate:date("Y-m-d")}</p>

In JSON, dates come across like this:
"latestESDate":"2029-01-31 00:00:00.0"

Jamie Avins
9 Aug 2010, 7:49 AM
What about the supported devices?

9 Aug 2010, 9:38 AM
Yes, by Safari, I mean Safari that runs both on the desktop as well as iOS4.

Jamie Avins
10 Aug 2010, 7:37 AM
Perfect, that what I wanted to know.

8 Sep 2010, 10:14 PM
I wouldn't say it's a bug in Touch. Since you didn't specify a date format, it runs the value through the native browser Date.parse. It seems Chrome treats that as a valid date by default, but Safari doesn't.

However, you can easily work around it by specifying the format:

onReady: function(){
console.log(Date.parse('2029-01-31 00:00:00.0'));

Ext.regModel('Test', {
fields: [{
name: 'dob',
type: 'date',
dateFormat: 'Y-m-d H:i:s.u'

var store = new Ext.data.Store({
autoLoad: true,
model: 'Test',
proxy: {
type: 'ajax',
url: 'test.json',
reader: {
type: 'json',
root: 'data'
listeners: {
read: function(){

Where the underlying data is:

"data": [{
"dob": "2029-01-31 00:00:00.0"

10 Sep 2010, 3:21 PM
No, that doesn't quite work either. As I pointed out in this post (http://www.sencha.com/forum/showthread.php?108571-Dates-coming-across-as-NaN-on-Safari-only-for-certain-formats), the dates still come access as NaN even with adding the date format in the model.

10 Sep 2010, 6:45 PM
The above, on Safari 5 and my iPad shows the appropriate date in the read callback.