开发者

Making a countdown based on MySQL

开发者 https://www.devze.com 2023-02-26 05:12 出处:网络
The software I use logs what time a song is played in a database with a timestamp formatted like 2011-04-13 17:55:46. It also logs the len开发者_如何学Pythongth of the song in milliseconds. How can I

The software I use logs what time a song is played in a database with a timestamp formatted like 2011-04-13 17:55:46. It also logs the len开发者_如何学Pythongth of the song in milliseconds. How can I get that timestamp converted to milliseconds? Secondly, how can I calculate the time remaining so I could use it to cause the page to refresh when time is up?


Code:

var date = new Date("2011-04-13 17:55:46");
var milliseconds = date.getTime(); 
alert (milliseconds);

Output:

1302697546000

For date difference, many duplicate posts:

How to calculate date difference in javascript

Get difference between 2 dates in javascript?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号