Reputation: 43
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
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
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