117Chapter 10Strings, Math, and Dateshowever, extract components of (Windows 2003 server web)
117Chapter 10Strings, Math, and Dateshowever, extract components of the Dateobject via a series of methods that you apply to aDateobject instance. Table 10-1 shows an abbreviated listing of these properties and infor- mation about their values. Table 10-1: Some Date Object MethodsMethodValue RangeDescriptiondateObj.getTime()0-…Milliseconds since 1/1/70 00:00:00 GMTdateObj.getYear()70-…Specified year minus 1900; four-digit year for2000+ dateObj.getFullYear()1970-…Four-digit year (Y2K-compliant); version 4+ browsersdateObj.getMonth()0-11Month within the year (January = 0) dateObj.getDate()1-31Date within the monthdateObj.getDay()0-6Day of week (Sunday = 0) dateObj.getHours()0-23Hour of the day in 24-hour timedateObj.getMinutes()0-59Minute of the specified hourdateObj.getSeconds()0-59Second within the specified minutedateObj.setTime(val)0-…Milliseconds since 1/1/70 00:00:00 GMTdateObj.setYear(val)70-…Specified year minus 1900; four-digit year for2000+ dateObj.setMonth(val)0-11Month within the year (January = 0) dateObj.setDate(val)1-31Date within the monthdateObj.setDay(val)0-6Day of week (Sunday = 0) dateObj.setHours(val)0-23Hour of the day in 24-hour timedateObj.setMinutes(val)0-59Minute of the specified hourdateObj.setSeconds(val)0-59Second within the specified minuteBe careful about values whose ranges start with zero, especially the months. ThegetMonth()and setMonth()method values are zero based, so the numbers are one lessthan the month numbers you are accustomed to working with (for example, January is 0, December is 11). You may notice one difference about the methods that set values of a Dateobject. Ratherthan returning some new value, these methods actually modify the value of the Dateobjectreferenced in the call to the method. Date CalculationsPerforming calculations with dates frequently requires working with the millisecond values ofthe Dateobjects. This is the surest way to compare date values. To demonstrate a few Dateobject machinations, Listing 10-1 displays the current date and time as the page loads. Another script shows one way to calculate the date and time seven days from the currentdate and time value. Caution
Note: In case you are looking for affordable webhost to host and run your web application check Vision cheap hosting services