countdown timer from current date to specific date in javascript -


// thought of .. guess current date format , specified date format different. please.

    `<script>      var oneday = 24*60*60*1000; // hours*minutes*seconds*milliseconds      var firstdate = new date();      var seconddate = new date(2016,02,20);      var diffdays = math.round(math.abs((firstdate.gettime() - seconddate.gettime())/(oneday)));      document.getelementbyid("demo").innerhtml =diffdays;      </script>` 

you can -

<script>    var oneday = 24*60*60*1000; // hours*minutes*seconds*milliseconds    var firstdate = new date();    var seconddate = new date(2016,02,20);    var diffdays = 'expired';    if(seconddate>=firstdate){       diffdays = parseint((seconddate - firstdate)/oneday) + ' days left';    }    document.getelementbyid("demo").innerhtml =diffdays; </script> 

here fiddle fiddle


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -