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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -