jQuery countdown timer - countdown to end of each

2019-05-10 15:33发布

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条回答
小情绪 Triste *
2楼-- · 2019-05-10 15:53

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>
查看更多
登录 后发表回答