jQuery countdown timer - countdown to end of each month, starting first?

和自甴很熟 提交于 2019-12-07 12:22:27

问题


A client wants to have a countdown for his monthly sale, starting on the first of each month (server time = local time = time that should be used), and have it countdown till the end of the month (28 days 7 hours 6 minutes remaining). How would the logic behind this look like? Is there a library/plugin that does this by default?

Any pointers in the right direction would be amazing.


回答1:


You must check this, I think it's what you need:

http://keith-wood.name/countdown.html

UPDATE

This is the code you need:

    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="jquery.plugin.js"></script>
        <script src="jquery.countdown.js"></script>
        <script>
            $(function () {
                var date = new Date();
                date = new Date(date.getFullYear(), date.getMonth() + 1, 1);
                $('#defaultCountdown').countdown({until: date});
            });
        </script>
    </head>

    <body>
        Time left:
        <div id="defaultCountdown"/>        
    </body>


来源:https://stackoverflow.com/questions/24009771/jquery-countdown-timer-countdown-to-end-of-each-month-starting-first

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