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?
Asked
Active
Viewed 140 times
0

reformed
- 4,505
- 11
- 62
- 88
-
1Seems like a duplicate of [http://stackoverflow.com/questions/5657151/countdown-based-on-mysql-entry] – Teetrinker Apr 14 '11 at 18:06
-
Why don't you just store the timestamp in millisecond? – Shoe Apr 14 '11 at 21:57
-
The duplicate question did not really get an answer, maybe Austin decided to re-ask the question under a different account? – Johan Apr 14 '11 at 22:34
-
You want this in Javascript right? – Johan Apr 14 '11 at 22:49
-
I couldn't get access to my other account. Yes, javascript would be fine. – user708456 Apr 15 '11 at 17:41
1 Answers
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:

Community
- 1
- 1

Jitesh Sojitra
- 3,655
- 7
- 27
- 46