Date Object Calculations : Date Calculation « Date Time « JavaScript DHTML






Date Object Calculations

   

<html> 
<head> 
<title>Date Calculation</title> 
<script type="text/javascript"> 
function nextWeek() { 
    var todayInMS = today.getTime(); 
    var nextWeekInMS = todayInMS + (60 * 60 * 24 * 7 * 1000); 
    return new Date(nextWeekInMS); 
} 
</script> 
</head> 
<body> 
Today is: 
<script type="text/javascript"> 
    var today = new Date(); 
    document.write(today); 
</script> 
<br> 
Next week will be: 
<script type="text/javascript"> 
    document.write(nextWeek()); 
</script> 
</body> 
</html> 

   
    
    
  








Related examples in the same category

1.Calculate the days between two dates
2.Get your timezone
3.Append date to string
4.Putting a Time Stamp on a Page