Search code examples
javascriptjsonangulardatewcf

Pass Date '1900-01-01' from angular to wcf


When I call with following json

{

      "EndDate": "\/Date(" + date + ")\/"
}

It changes to 1970 year

When I call without Date, it throws serialization issue.

I am using angular 7 and WCF.

How could I pass '1900-01-01 00:00:00' to wcf from angular

Thanks


Solution

  • JSON does not support Date objects so you need to use a timestamp (int) or a DateString(string) and finally parse it in WCF

    {
    
      "EndDate":  date.getTime() // Timestamp in ms 
     }