I am using backgrid to display JSON results from the backend Db. One of the fields is time in seconds from 1970 (eg. 1362578461000) when the Backbone view receives this data backgrid sends it off to moment for formating. Moment then throws a javaScript TypeError exception indicated on line 758 of Moment.js (v.2.0.0)
TypeError: string.indexOf is not a function
The column format looks like this:
var columns = [{
name: "startTime",
label: "Start Time",
editable: false,
cell: "moment"
}, {
name: "endTime",
label: "End Time",
editable: false,
cell: "moment"
}];
Putting a brakepoint in Firebug it looks like Moment thinks that the value is a integer rather then a string.
utc()moment.js (line 960)
input = 1362578461000
format = "YYYY-MM-DDTHH:mm:ssZ"
lang = undefined
And the call to makeDateFromStringAndFormat looks like this:
makeDateFromStringAndFormat()moment.js (line 758) config = Object { _useUTC=true, _isUTC=true, _i=1362578461000, more...}
Any ideas as to what I can do to fix/get around this?
Thanks