Creating Dynamic Pages

 

Activities

 

 

Date Object

 

Create a new Date object:

 

Syntax:

 

            dateObj = new Date(arguments);    

 

            or

 

            dateObj = new Date(yr, mth, dy, hrs: mins;secs)

 

            or

 

            dateObj= new Date("mth, dy, yr, hrs: mins;secs)

 

Examples:

            dateObj = new Date("October 8, 2000, 10:00:00")

            Today = new Date(2000, 10, 8, 10:00:00")

            now = new Date(2000, 10, 8, 10:00:00")

 

 

 

 

Methods

dateObj.getYear() // return year minus 1900

dateObj.getMonth() // return month from 0-11

dateObj.getDay()  // return day of week from Sunday (0)- Saturday(6)

dateObj.getDate()  // return date in month from 1-31

dateObj.getTime() // return milliseconds since Jan. 1, 1970 00:00:00

dateObj.getHours()  // return hour of day in military time from 0 to 23

dateObj.getMinutes()// return minutes of hour from 0-59

dateObj.getSeconds()// return seconds of minute from 0-59

 

dateObj.setYear() // set year minus 1900

dateObj.setMonth() // set month from 0-11

dateObj.setDay()  // set day of week from Sunday (0)- Saturday(6)

dateObj.setDate()  // set date in month from 1-31

dateObj.setTime() // set milliseconds since Jan. 1, 1970 00:00:00

dateObj.setHours()  // set hour of day in military time from 0 to 23

dateObj.setMinutes()// set minutes of hour from 0-59

dateObj.setSeconds()// set seconds of minute from 0-59

 

 

Day and Month Arrays

 

dayOfWeeks = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

 

monthOfYear = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

 

Check if the day is valid:

 

If  (now.getDay() > 0 && now.getDay() < 6)

   {

    // it is a valid day

   }

 

Customizing the message to reflect the time of day: Good morning, Good afternoon, Good evening

 

If (now.getHour() < 5)

   {

    // this is before 5 AM, Early birds?

  }

 

If (now.getHour() > 23 )

   {

    // this is after 11 PM, Burning mid-night oil?

  }

 

Arrays for Special Events and Day:

 

paymentCalender = new Array;

paymentCalender [1] = "Class Begin Jan. 8";

paymentCalender [2] = "Late Registration and Drop/Add: Jan. 8-12";

paymentCalender [3] = "Weekend Class Begin Jan. 12";

paymentCalender [4] = "Last Day for Full Refund: Jan. 12";

paymentCalender [5] = "Payment Deadline: Jan. 12";

 

holidayCalS2001 = new Array;

acamedicCalender[1] = "Class Begin Jan. 8";

academicCalender[2] = "Martin Luther King Jr. Holiday: Jan. 15";

academicCalender[3] = "Spring Break Begins: March 5-11";

academicCalender[4] = "Last Day to Withdraw: March 16";

academicCalender[5] = "Last Day of Classes and Final Exams: April 30-May 6";

academicCalender[6] = "Commencement: May 9";