问题
What I'm trying to do seems like it should be simple but is proving tricky. I need a countdown script that uses a target date and gives me three separate figures - namely Days, Hours and Minutes to that date - that I can then plug into the page in the appropriate place. I tried jCountdown but while it is highly customisable I still haven't managed to get what I need. I'd like to
I can do it with php but I don't really want to combine php into a static html page that already has some jquery in there. Trying to keep things as simple as possible.
What I want is for the user to be able to specify a date in the backend code that will then give three separate readouts - the number of days, hours or minutes to that date. Not a total of each but say 3 days, 3 hours and 5 minutes.
I've taken a look at this
http://jsfiddle.net/McdSV/
which again has a total number of each, whether it is days, hours, etc. and still gives it as one printout. Seems to be a consistent problem that I am finding.
Any guidance would be appreciated.
回答1:
You should be able to do the math yourself and print it out. Use modulus to get the remainder in minutes and then floor the days.
In the example you get seconds by subtracting the two time objects so lets start there:
totalseconds % 60, remainder of seconds
totalseconds / 60, total minutes
totalminutes % 60, remainder of minutes
etc...
See for code: http://jsfiddle.net/jHVnz/
回答2:
Have you seen this plugin? http://www.keith-wood.name/countdown.html
回答3:
In the example you get seconds by subtracting the two time objects so lets start there:
totalseconds % 60
, remainder of secondstotalseconds / 60
, total minutes
来源:https://stackoverflow.com/questions/8567241/countdown-to-a-specific-date