Search code examples
jquerytimercountdown

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


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.


Solution

  • 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>