Date to Day Calculator

Example

Enter a date:
Day: Month: Year:

Code

Put this in the head part of the document
<script language="JavaScript">
<!--
function calculate(){
var Day = document.getForm.getDay.value
var Month = document.getForm.getMonth.value
var Year = document.getForm.getYear.value
Month = Month - 1
var theDate = new Date()
theDate.setDate(Day)
theDate.setMonth(Month)
theDate.setYear(Year)
var month = Month + 1
var dayArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") 
alert("The day is: " + dayArray[theDate.getDay()] + "( " + Day + "/" + month + "/" + Year + " )")
}
//-->
</script>
Put this in the body part of the document
<form name="getForm">
Enter a date:<br />
Day: <input type="text" name="getDay" length=2 value="01" size="2" />
Month: <input type="text" name="getMonth" length=2 value="01" size="2" />
Year: <input type="text" name="getYear" length=4 value="2005" size="4" />
<br />
<input type="button" value="Calculate!" onClick=calculate() />
</form>
Home | Code | Learn
© 2007-2008 ProgLogic, all rights reserved. | ProgLogic.com is created by Stijn Strickx. | e-mail