aaakanks
aaakanks

Reputation: 43

how can I Convert "Tue Nov 26 2019 16:00:00 GMT-0800" to .net json date formate "\/Date(1574812800000)\/" formate?

I need to conver my ison date formate to .net json date formate in javascript

like this Tue Nov 26 2019 16:00:00 GMT-0800" to "/Date(1574812800000)/"

Upvotes: 0

Views: 91

Answers (2)

georgeawg
georgeawg

Reputation: 48968

With JavaScript:

var dt = new Date("Tue Nov 26 2019 16:00:00 GMT-0800");

var format = "/Date("+dt.valueOf()+")/";
console.log(format);

Upvotes: 1

Locoluis
Locoluis

Reputation: 804

You can use Moment.js:

moment("Tue Nov 26 2019 16:00:00 GMT-0800", "ddd MMM D YYYY H:m:s [GMT]ZZ").format("[/Date(]x[)/]")

You should get the result:

/Date(1574812800000)/

The timestamp you supplied corresponds to May 23, 2001 at midnight GMT.

Upvotes: 0

Related Questions