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 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