Greetings,
I am working on a piece of code that totals how many days have passed so far this year. This is where I am at and I am close, but I cannot see my error:
var month = new Array(12);
month [0] = 31; //jan31
month [1] = 28; //feb28
month [2] = 31; //mar31
month [3] = 30; //apr30
month [4] = 31; //may31
month [5] = 30; //jun30
month [6] = 31; //jul31
month [7] = 31; //aug31
month [8] = 30; //sep30
month [9] = 31; //oct31
month [10] = 30; //nov30
month [11] = 31; //dec31
var currentDate = new Date(); //creates a date variable
monthValue = currentDate.getMonth(); //gets month in numeric format
dateValue = currentDate.getDate(); //gets date in numeric format
var ytd = 0; //year to date
function julianDate() {
for (var i=0; i<monthValue; i++) { // totals days of previous months
ytd += month + dateValue; // adds days from previous months to today's date to get the julian date.
}
window.status = ytd; //
document.write(+ytd+ " days have passed so far this year.");
}
julianDate();
any and all assistance is appreciated,
thanx,
Mr Moose
I am working on a piece of code that totals how many days have passed so far this year. This is where I am at and I am close, but I cannot see my error:
var month = new Array(12);
month [0] = 31; //jan31
month [1] = 28; //feb28
month [2] = 31; //mar31
month [3] = 30; //apr30
month [4] = 31; //may31
month [5] = 30; //jun30
month [6] = 31; //jul31
month [7] = 31; //aug31
month [8] = 30; //sep30
month [9] = 31; //oct31
month [10] = 30; //nov30
month [11] = 31; //dec31
var currentDate = new Date(); //creates a date variable
monthValue = currentDate.getMonth(); //gets month in numeric format
dateValue = currentDate.getDate(); //gets date in numeric format
var ytd = 0; //year to date
function julianDate() {
for (var i=0; i<monthValue; i++) { // totals days of previous months
ytd += month + dateValue; // adds days from previous months to today's date to get the julian date.
}
window.status = ytd; //
document.write(+ytd+ " days have passed so far this year.");
}
julianDate();
any and all assistance is appreciated,
thanx,
Mr Moose