views:

254

answers:

1

I am pulling in data from a JSON file using FBJS AJAX. On of the values in the json file is a date. The date has a UTC format, Date(1255535021000-0600).

However, I am getting an "invalid date" or "NaN" error whatever I do.

I have tried the following: new Date(1255535021000-0600), new Date(1255535021000), Date.parse(1255535021000-0600), Date.parse(1255535021000).

In old fashioned Javascript it works perfectly, but not when using FBJS.

What do I do to transform this into a usable date?

+1  A: 

To get around FBJS terrible parsing and lackluster constructor I created an empty Date() and then called setTime().

var tmp = new Date();
tmp.setTime(1255535021000);

This is a workable solution for now. However, I think that Facebook should do a better job providing consistent environment for the objects, like Date, that are, at least superficially, regular javascript.

zznq