Countdown to a specific date

杀马特。学长 韩版系。学妹 提交于 2019-12-31 03:08:09

问题


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 seconds
totalseconds / 60, total minutes



来源:https://stackoverflow.com/questions/8567241/countdown-to-a-specific-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!