Making a countdown based on MySQL
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?
精彩评论