var d = new Date("6/13/1986");
var dateString = d.toDateString();
alert(dateString);
var dayOfWeekStr;
var monthStr;
var twoDigitYear;
switch(d.getDay()) {
case 0:
dayOfWeekStr = "Sunday";
break;
case 1:
dayOfWeekStr = "Monday";
break;
case 2:
dayOfWeekStr = "Tuesday";
break;
case 3:
dayOfWeekStr = "Wednesday";
break;
case 4:
dayOfWeekStr = "Thursday";
break;
case 5:
dayOfWeekStr = "Friday";
break;
case 6:
dayOfWeekStr = "Saturday";
break;
default:
dayOfWeekStr = null;
break;
}
switch (d.getMonth()) {
case 0:
monthStr= "January";
break;
case 1:
monthStr= "February";
break;
case 2:
monthStr= "March";
break;
case 3:
monthStr= "April";
break;
case 4:
monthStr= "May";
break;
case 5:
monthStr= "June";
break;
case 6:
monthStr= "July";
break;
case 7:
monthStr = "August";
break;
case 8:
monthStr= "September";
break;
case 9:
monthStr= "October";
break;
case 10:
monthStr = "November";
break;
case 11:
monthStr= "December";
break;
default:
monthStr = null;
break;
}
twoDigitYear = (twoDigitYear = d.getYear()%100) > 10 ?
"" + twoDigitYear : "0" + twoDigitYear;
alert("The date was " + monthStr + " " + d.getDate() + ", '" + twoDigitYear + ". That day was a " + dayStr);
d = new Date("2/31/2012"); // yields: 2 Mar 2012
Users browsing this forum: No registered users and 92 guests