phpjqueryjquery-countdown

jQuery countdown current date to end date


I am using this plugin : http://keith-wood.name/countdown.html
I want to put countdown script code in php .
I have a php echo value like 2016-02-29 and this is countdown end date .
How to add this value to this countdown plugin to start a countdown from current date to end date?


Solution

  • From the plugin documentation

    $('#defaultCountdown').countdown({until: new Date(2016, 2-1, 29)}); 
    

    For instance

    <?php
    $date = strtotime('2016-02-29');
    ?>
    $('#defaultCountdown').countdown({until: new Date(<?= (int)date('Y', $date) ?>, <?= (int)date('m', $date) ?>-1, <?= (int)date('d', $date) ?>)});