Show Next 7 Days by Date

[Total: 0    Average: 0/5]

This example shows how to determine the date and put the next 6 days values in the header of a column.

Head Code:

<script>
/* adds 1 day in milliseconds to the time */
function addDay(_a,_b){_a.setTime(_a.getTime()+_b*1000*60*60*24);}
/* outputs the data */
function w(a,b){document.write(a+" -> "+b+"<BR>");}
function o(a){document.write(a);}
/* our date object */
var _d = new Date();
</script>

Body Code:

<table border=1>
<tr>
<td><script>o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
<td><script>addDay(_d,1);o(_d.getDate());</script></td>
</tr>
</table>
<HR>
OTHER DATE STUFF:<BR>
<script>
w('Date',_d.getDate());
w('Day',_d.getDay());
w('FullYear',_d.getFullYear());
w('Hours',_d.getHours());
w('Milliseconds',_d.getMilliseconds());
w('Minutes',_d.getMinutes());
w('Month',_d.getMonth());
w('Seconds',_d.getSeconds());
w('Time',_d.getTime());
w('Timezoneoffset',_d.getTimezoneOffset());
w('UT-Date',_d.getUTCDate());
w('UT-Day',_d.getUTCDay());
w('UT-FullYear',_d.getUTCFullYear());
w('UT-Hours',_d.getUTCHours());
w('UT-Milliseconds',_d.getUTCMilliseconds());
w('UT-Minutes',_d.getUTCMinutes());
w('UT-Month',_d.getUTCMonth());
w('UT-Seconds',_d.getUTCSeconds());
w('Year',_d.getYear());
var _months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
document.write('<BR><BR>The month is = '+_months[_d.getMonth()]);
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *