2
votes

I am working in a simple Emberjs application where I am using the following versions:

DEBUG: -------------------------------

DEBUG: Ember : 1.3.2+pre.25108e91

DEBUG: Ember Data : 1.0.0-beta.6

DEBUG: Handlebars : 1.2.1

DEBUG: jQuery : 1.11.0

DEBUG: -------------------------------

Suppose I have the following model:

class App.Event extends DS.Model
  startDate: DS.attr 'date', { defaultValue: new Date}
  endDate: DS.attr 'date', { defaultValue: new Date}
  guests: DS.attr 'number'

  client: DS.belongsTo 'client'
  room: DS.belongsTo 'room'
  eventType: DS.belongsTo 'eventType'

  eventServices: DS.hasMany 'eventService'
  eventPayments: DS.hasMany 'eventPayment'

everytime I try to save an instance of this model like this:

event.save()

Emberjs/Ember Data is serializing my date fields like this. Example, if my start date was:

2014-02-12 21:27:52 -0500

emberjs would serialize it like this:

1392258472591

Does anybody knows why is doing that? My rails backend does not recognize this format.

Any help would be appreciated!

2

2 Answers

2
votes

It's the milliseconds-since-epoch date, which is how JavaScript stores dates.

x = new Date()
x.getTime(); // 1392263479591
2
votes

I downloaded the latest build of Ember Data beta 7 and the issue has been fixed. Now me date fields are being serialized with this format:

"Fri, 14 Feb 2014 22:21:07 GMT"