Javascript Data Type How to - Get next 12:00:00PM for date








Question

We would like to know how to get next 12:00:00PM for date.

Answer


<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
var nextNoon = new Date();
if (nextNoon.getHours()>=12) {<!--  www . j av a 2s.  com-->
   nextNoon.setDate(nextNoon.getDate()+1)
}
nextNoon.setHours(12,0,0,0);
document.writeln(nextNoon);                 
</script>
</body>
</html>

The code above is rendered as follows: