0

I am using an API in my code and the Date i get is something like this

"DateOfBirth":Date(-2208960000000-0800)

I am using Curl in my php code, If I try the API in fiddler or any REST client I get correct date like 22-3-2010, I thought that 2208960000000 could be unix timestamp, but seems very odd that how in REST client the response is different and totally different when I use in PHP code,

EDIT: The response from API is XML but I am using "Content-type: application/json" in my CURL, I then use json_Encode() and can easily traverse through API, I think when I get the data by JSON it sends me this "DateOfBirth":Date(-2208960000000-0800) Any help in this regard?

Thank you

user3680538
  • 65
  • 1
  • 6
  • 1
    Can you show the code that you're using to generate / parse the date? – newfurniturey Jun 13 '14 at 12:57
  • 1
    That looks almost like a JSON date from .NET. See http://stackoverflow.com/questions/10286204/the-right-json-date-format. Unfortunately, PHP's `json_decode()` doesn't recognize it. – Barmar Jun 13 '14 at 13:02
  • @newfurniturey the date is generated through the API, I am just getting data from the API – user3680538 Jun 13 '14 at 13:12
  • Do you use 32 bit software (on 32 bit system) ? Looks like some kind of overflow, keep in mind JS time's are in milliseconds rather than seconds. – Daniel W. Jun 13 '14 at 13:30

1 Answers1

0

Try this :

 var isWcfJsonDate = /\/Date(.*)\//.test("Your Date String");
        if (isWcfJsonDate)
        {
                dateStr = dateStr.match(/Date\((.*?)\)/)[1];
                dateValue = new Date(parseInt(dateStr));
                return dateValue;
        }
        dateValue = new Date(dateObject);
        console.log( dateValue); //Use your date value