0

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(1405699200)/

flofreelance
  • 874
  • 1
  • 11
  • 30

2 Answers2

2

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());
curveball
  • 4,195
  • 13
  • 36
  • 46
0
/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

Sagar Hani
  • 146
  • 1
  • 8