-2

I have a date like this var jsDate = "2017-01-01";

I want to put this jsDate like C# date: (/Date(1425408717000)/)

Also how can put this c# date /Date(1425408717000)/ into JavaScript Json date?

Nope
  • 22,147
  • 7
  • 47
  • 72
  • momentJS can parse ASP.NET's weird date format: http://momentjs.com/docs/#/parsing/asp-net-json-date/ . I can't think of a reason you'd need to convert it back the other way on the JS side though, you should be able to just send an ISO date string to the server. – ADyson Oct 12 '17 at 15:21
  • Please, please, please don't use `(/Date(1425408717000)/)` it's an abomination. `"2017-01-01"` is a standard format defined by [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) and easily parseable (is that a word) – phuzi Oct 12 '17 at 15:22
  • @phuzi if OP is getting data from some older ASP.NET ASMX or WCF webservices they may have no choice in the matter - the services spit out dates in this bizarre format when returning data. But as I mentioned earlier, momentJS can read them into a moment object (which can then be converted into a JS Date object, or a string) so it's not a massive issue, as long as using momentJS is not a problem for the OP. – ADyson Oct 12 '17 at 15:23

1 Answers1

0

In JavaScript you can try: (new Date("2017-01-01")).getTime() , which will give you 1483228800000 if that's what you are looking for

Aleksey Solovey
  • 4,153
  • 3
  • 15
  • 34