Convert Javascript Date To Json Date Format
I'm working with an API which expects json date format. I need to convert my javascript date Sat Jan 17 1970 07:28:19 GMT+0100 (Romance Standard Time) To json date format /Date
Solution 1:
Is anything of the following ok?
console.log(new Date('Sat Jan 17 1970 07:28:19 GMT+0100 (Romance Standard Time)').toJSON());
console.log(new Date('Sat Jan 17 1970 07:28:19 GMT+0100 (Romance Standard Time)').valueOf());
Solution 2:
/Date(1405699200)/
Here 1405699200
is your date in epoch format.
You can do this :
var myDate = new Date("July 1, 1978 02:30:00"); // Your timezone!
var myEpoch = myDate.getTime()/1000.0;
document.write(myEpoch);
To convert human readable date format to Epoch format : https://www.epochconverter.com/programming/#javascript
Post a Comment for "Convert Javascript Date To Json Date Format"