Search code examples
phpdatetimecountdown

How to convert date-time difference into countdown?


Using this I can get the date and time difference.

$first_date = new DateTime(“2012-11-30 17:03:30”);
$second_date = new DateTime(“2012-12-21 00:00:00”);

$difference = $first_date->diff($second_date);

echo format_interval($difference);

How can i convert it from static to run as count-down timer?


Solution

  • Try this jquery plugin

    <script type="text/javascript" src="/path/to/jquery.countdown.js"></script>
    
    <script type="text/javascript">
    $(function() {
        $('.yourCountdownContainer').countdown({
            date: "June 7, 2087 15:03:26"
        });
    });
    </script>
    

    Form more details enter link description here