Loop each hour to the same hour tomorrow - Javascript Date Operation

Javascript examples for Date Operation:Date Calculation

Description

Loop each hour to the same hour tomorrow

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// w w  w . ja  va 2  s .  c  om
var i;
var date = new Date;
var hours = date.getHours();
for(i = hours; i <= hours+24; i++) {
    if(i<25){
        console.log(i);
    }else{
        console.log(i-24);
    }
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials