I'm using the following JS to calculate X days ahead of today's date. The output seems to work fine, except the result doesn't consider the days in each month. Therefore, if today is the 26th and I add 9 days, it's outputting the day as the 35th which obviously doesn't make sense.
<script>
window.onload=function(){
var dateObj = new Date();
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var month = months[dateObj.getMonth()]; //months from 1-12
var day = dateObj.getUTCDate() +9;
var year = dateObj.getUTCFullYear();
newdate = day + " " + month + " " + year;
document.getElementById("date").innerHTML=(newdate);
}
</script>
How can we get it to output the accurate date?