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

2 Answers 2

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());

Sign up to request clarification or add additional context in comments.

1 Comment

new Date('Sat Jan 17 1970 07:28:19 GMT+0100 (Romance Standard Time)').valueOf() works fine! Thanks you!
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.