Countdown based on MySQL entry

I have a database that logs the date and time a song was played in a format like 2011-04-13 17:55:46. It also logs the length of the song in milliseconds. How would I make a live countdown for the user to see as well as a refresh countdown?



For Javascript, you can use the Date() object created from a string with the given time (you can print it to the screen in a hidden input, span, or whatever). I assume the end time is when the song ends. You can calculate this very simply based on the difference between the play time and the song length. When you say "refresh countdown," do you mean if they refresh the page? Well, I'm not sure how the song would keep playing at the given time, but you could check that the song was started and use the time you have above and do your calculation again.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.