0

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 length 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?

reformed
  • 4,505
  • 11
  • 62
  • 88

1 Answers1

0

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?

Community
  • 1
  • 1
Jitesh Sojitra
  • 3,655
  • 7
  • 27
  • 46