Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

javascript - Calculating milliseconds from epoch

Given that I have: mm, dd, yy, hh:mm, am/pm, what is the recommended/easiest way to convert that data into milliseconds from epoch?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Everytime I get an upvote on this answer, I'm reminded that my answer doesn't actually answer the question.

OP: If you can parse your string into the following format, you can use one of the other answers. MM/DD/YYYY HH:MM:SS AM EDT (It's important to specify the timezone; epoch is based on the meridian)

let milliseconds = new Date("1/20/1982 5:00 PM EST").getTime()
console.log(milliseconds);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...