I have a calendar entry page that calculates the day of the week for the date entered based on a function.
Internet explorer gets the days right but Moz outputs the days two off from what they really are.
The date is entered like 20040331, the code snippet below processes the form value
strDate = document.eventadd.FromDate.value;
strYear = strDate.substring(0,4);
strMonth = strDate.substring(4,6);
strDay = strDate.substring(6,8);
var months = new makeArray(‘Jan.’,’Feb.’,’Mar.’,’Apr.’,’May’,’Jun.’,’Jul.’,’Aug.’,’Sep.’,’Oct.’,’Nov.’,’Dec.’);
var daysofweek = new makeArray(‘Sunday’,’Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’);
var jMonth = parseInt(strMonth);
jMonth=jMonth-1;
var date = new Date(strYear,jMonth,strDay);
var day = date.getDate();
var year = date.getYear();
var month = date.getMonth() + 1;
I believe that this function the piece that is off
function DayOfWeek(day,month,year) {
var a = Math.floor((14 – month)/12);
var y = year – a;
var m = month + 12*a – 2;
var d = (day + y + Math.floor(y/4) – Math.floor(y/100) +
Math.floor(y/400) + Math.floor((31
return d + 1;
}
Here is the url where the page code is active.
Thanks