Search code examples
javascriptjquerycountdown

countdown jquery current data


I have a countdown java script code

    <script type="text/javascript">  
        $('document').ready(function() {
            'use strict';
            $('.countdown').final_countdown({
                'start': 1452402000,
                'end': 1458298800,
                'now':  1452402000
            });
        });
    </script>

I want to set 'now' to $.now() or get the current date but when I put it

'now': $.now()

could any on help


Solution

  • Looks like final_countdown expects the time as Unix time (seconds since 1.1.1970) but $.now() returns milliseconds since 1.1.1970

        $('document').ready(function() {
            'use strict';
            $('.countdown').final_countdown({
                'start': 1452402000,
                'end': 1458298800,
                'now':  Math.floor($.now() / 1000)  // strip the milliseconds
            });
        });