Skip to content
Advertisement

Javasacript Countdown timer in Days, Hours, Minute, Seconds

I’m trying to create a time-based count down clock. It is not based upon current_dates. The initial time that will be pulled will be from a separate php file. This will be for a browser based-game. When someone clicks the button to initiate this script. it will check if certain requirements are met and if so then this script will initiate. Based upon the level of the object it will pull the initial timer for that proceeding level. Hope that makes sense. Anyhow I based the timer script off of the first code I provide.

This script only accounts for minutes and seconds. I modified it to include days and hours as well. Somewhere in the process I have messed up and the script doesn’t even work at all. I’m also not quite sure if this would be the best method to calculate this. So, if you have a cleaner method at doing this please share. Thank you in advance.

This script is based off of a minutes / seconds script I saw. Here’s the original source:

JavaScript

Here is the modified script that I am trying to include days, hours, minutes and seconds.

JavaScript

Advertisement

Answer

I finally got back to looking at this and re-wrote the code and this works like a charm.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement