Click to See Complete Forum and Search --> : PLs Help its fast


gunjan
04-24-2003, 02:30 AM
I want to get the dates of all the sunday's in an year
wats the script pls help!!!!!

Charles
04-24-2003, 05:24 AM
<script type="text/javascript">
<!--
function sundays (year) {
var ONE_DAY = 86400000;
var ONE_WEEK = ONE_DAY * 7;
var firstJan = new Date (year, 0, 1);
var zerothSun = new Date (firstJan.valueOf() - ONE_DAY * firstJan.getDay())
var s = new Array();
s [0] = new Date (zerothSun.valueOf() + ONE_WEEK);
var j = 0;
while (s[j++].getFullYear() == year) {s[j] = new Date (s [j-1].valueOf() + ONE_WEEK)};
s.length = s.length-1;
return s;
}

s = sundays(2003)
for (j = 0; j < s.length; j++) {document.write(s[j], '<br>')};
// -->
</script>