Javascript Data Type How to - Calculate remaining time








Question

We would like to know how to calculate remaining time.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.js"></script>
</head><!--   w w  w  .  ja  va 2 s.c o  m-->
<body>
<script type='text/javascript'>
    var x = moment(new Date(2024, 3, 12)).from(new Date());
    document.writeln(x);
</script>

</body>
</html>

The code above is rendered as follows: