Archive for September, 2007

206 . Chapter 12 creates a Date object (Web site)

Sunday, September 30th, 2007

206 . Chapter 12 creates a Date object usingGMT instead of local time, as it would if the method was not used: gmtDate = new Date(Date.UTC(99, 11, 1, 0, 0, 0)) The general syntax of the method is: Date.UTC(year, month, day [, hrs] [, min][, sec]) All attributes should be specified as integers. Time-Related Methods of Other Objects setTimeout() The setTimeout() method evaluates an expression after a specified number of milliseconds have elapsed. Its general syntax is: timeoutID = setTimeout(expression, msec) timeoutID is an identifier used to identify the current timeout. expression is a stringexpression or property of an existingobject. It is normally a simple statement that is to be executed after the specified time has ticked off. msec is a numeric value, a numeric string, or a property of an existing object in millisecond units. The setTimeout() method evaluates an expression after a specified amount of time. Take a look at the followingexample: setTimeout() method

Click the button on the left for a reminder in 5 seconds; click the button on the right to cancel the reminder before it is displayed.


If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Web hosting domain names - Time and Date in JavaScript . 205 varnow=newDate()

Sunday, September 30th, 2007

Time and Date in JavaScript . 205 varnow=newDate() varar1=now.toLocaleString().split(”") document.write(”Thecurrenttimeis”+ar1[1]) The script s output is: The current time is 18:12:51 The general format of the converted string is: MM/DD/YY HH:MM:SS parse Methods parse() The parse() method accepts a date stringin the IETF standard and converts it to the number of milliseconds since January 1, 1970 00:00:00. The IETF standard date representation is: DayAbb, date MonthAbb year HH:MM:SS TimeZoneAbb An example for this standard is Mon, 25 Dec 2001 13:30:00 GMT. This method also understands the continental U.S. time zone abbreviations such as PST (Pacific Standard Time) and EST (Eastern Standard Time). However, time zones outside the United States (and their equivalent in Canada, for instance) do not have a standard abbreviation accepted by JavaScript. For such time zones the offset must be specified; that is, you must specify the difference in hours and minutes between the local time zone and Greenwich Mean Time. For example, in Mon, 25 Dec 2001 13:30:00 GMT+0430, GMT+0430 is shorthand for 4 hours, 30 minutes west of the Greenwich meridian. If you do not specify a time zone, the local time zone is assumed accordingto the settings of the clock in the operatingsystem. If your time zone is not set correctly, you should change it in the control panel, both on Macs and Windows- based machines. GMT is also known as Universal Coordinate Time, or UTC. The parse method is a static one. It does not belongto a specific instance of the Date object, but to the object type itself. Therefore, it is always used as Date.parse(). Here is an example for this method: varaDate=”Aug272001″ varbirthday=newDate() birthday.setTime(Date.parse(aDate)) UTC() The UTC() method takes a comma-delimited list and returns the number of milliseconds since January 1, 1970 00:00:00, Greenwich Mean Time (GMT, UTC). This is also a static method, so it is called alongwith the general Date object. You cannot use this method to refer to a specific date in the local time zone, because it constantly refers to the Universal Time Coordinate (GMT, UTC). For example, the followingstatement Chapter
Check Tomcat Web Hosting services for best quality webspace to host your web application.

204 . Chapter 12 (Free web hosting music) else if (lastDigit ==

Saturday, September 29th, 2007

204 . Chapter 12 else if (lastDigit == 3) suf = “rd” else suf = “th” // array for name of month var ar = new Array(12) ar[0] = “January” ar[1] = “February” ar[2] = “March” ar[3] = “April” ar[4] = “May” ar[5] = “June” ar[6] = “July” ar[7] = “August” ar[8] = “September” ar[9] = “October” ar[10] = “November” ar[11] = “December” var text = ar[month]+”" +date + suf alert(text) // July 4th (setTime modifies the entire instance) to Methods toGMTString() This method converts a date to a string, using the Internet GMT conventions. The conversion is done accordingto the operatingsystem s time zone offset and returns a stringvalue that is similar to the followingform: Tue, 30 Jul 2001 01:03:46 GMT The exact format depends on the platform. Here is a simple example: var now = new Date() var ar1 = now.toGMTString().split(” “) document.write(”The current time in Greenwich is ” + ar1[4]) A sample output of this script segment is: The current time in Greenwich is 01:08:21 toLocaleString() This method returns the date in the form of a string, using the current locale s conventions. If you are tryingto pass a date usingtoLocaleString, be aware that different locales assemble the stringin different ways. Usingmethods such as getHours, getMinutes, and getSeconds will give more portable results. The following example demonstrates this function:
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Time and Date in JavaScript . 203 ar[2]=”Tuesday” (Hosting your own web site)

Saturday, September 29th, 2007

Time and Date in JavaScript . 203 ar[2]=”Tuesday” ar[3]=”Wednesday” ar[4]=”Thursday” ar[5]=”Friday” ar[6]=”Saturday” document.write(”Thefirstdayofthemonthoccurredon”+ar[now.getDay()]) setHours() This method sets the hour attribute of a given instance of the Date object. Here is an example: varobj=newDate(”December4,199518:50:59″)//JSpressreleaseobj.setHours(obj.getHours() 2) alert(obj.getHours())//16 setMinutes() This method sets the minutes of a given Date instance. Here is a simple example: varobj=newDate(”December4,199518:50:59″)//JSpressreleaseobj.setMinutes(obj.getMinutes() 1) alert(obj.getMinutes())//49 setSeconds() The setSeconds() method sets the seconds of a given instance of the Date object type. The followingexample demonstrates its usage: varobj=newDate(”December4,200018:50:59″)//JSpressreleaseobj.setSeconds(obj.getSeconds() 9) alert(obj.getSeconds())//50 setTime() This method sets the number of milliseconds since January 1, 1970 00:00:00. It actually modifies all fields of its callingobject. Here is an example: var obj = new Date() obj.setTime(867999600000) var date = obj.getDate() var month = obj.getMonth() if (date < 10) var lastDigit = date else var lastDigit = date % 10 var exp = "" 12 // determine suffix if (lastDigit == 1) suf = "st" else if (lastDigit == 2) suf = "nd" Chapter
We recommend high quality webhost to host and run your jsp application: christian web host services.

Free web hosts - 202 . Chapter 12 determined as well in

Friday, September 28th, 2007

202 . Chapter 12 determined as well in the if-else construct. JavaScript then builds an appropriate message based on the current location of the user as well as the proper preposition. getTime() The getTime() method returns the number of milliseconds since January 1, 1970 00:00:00. The set Methods setYear() This method sets the year attribute of a given Date instance. The followingexample computes the day of the current date last year: var now = new Date() var year = now.getYear() now.setYear(year 1) ar = new Array(7) ar[0] = “Sunday” ar[1] = “Monday” ar[2] = “Tuesday” ar[3] = “Wednesday” ar[4] = “Thursday” ar[5] = “Friday” ar[6] = “Saturday” document.write(”Last year, the current day was ” + ar[now.getDay()]) First, an instance of the current date is created, and the current year is assigned to the variable year. The year attribute of the instance now is set to one year behind. The day attribute is then extracted from the modified instance, and a message is built based on that day, transformed to a string(via the array). setMonth() The setMonth() method sets the month attribute of a given instance of the Date object. The followingscript sets the month attribute of the current date to May: var now = new Date() now.setMonth(4) setDate() This method sets the date attribute of a given instance of the Date object. The followingscript prints the day on which the first day of the month occurred: var now = new Date() now.setDate(1) ar = new Array(7) ar[0] = “Sunday” ar[1] = “Monday”
We recommend high quality webhost to host and run your jsp application: christian web host services.

Time and Date in JavaScript . 201 getSeconds() (Web site directory)

Friday, September 28th, 2007

Time and Date in JavaScript . 201 getSeconds() This method returns the seconds of a given Date instance, from 0 to 59. You can use it in much the same way as you use the getMinutes() method. getTimezoneOffset() This method returns the time zone offset in minutes for the current locale. The time zone offset is the difference between local time and Greenwich Mean Time (GMT). Daylight savings time prevents this value from being a constant. The returned value is an integer representingthe difference in minutes. The followingscript shows how to use the user s time zone offset to figure out where he or she lives: if(confirm(”AreyouintheUnitedStates?”)) { varnow=newDate() varcurOffset=now.getTimezoneOffset() curOffset/=60//convertfromminutestohoursvarzone=”" varprep=”" if(curOffset==8) { zone=”westcoast” prep=”on” } elseif(curOffset==7) { zone=”mid-west” prep=”in” } elseif(curOffset==6) { zone=”mid-east” prep=”in” } else{ zone=”eastcoast” prep=”on” } alert(”Ithinkyoulive”+prep+”the”+zone+”!”) } elsealert(”Sorry,thisscriptisintendedforU.S.residentsonly”) ThescriptstartsbyaskingtheuserifheorshelivesintheUnitedStates.Ifnot,amessageisdisplayed.Otherwise,thefollowingcommandblockisexecuted.TheareaintheUnitedStatesisdeterminedaccordingtothedifferenceinhoursbetweenthelocaltimezoneandtheGMT.Theprecedingpreposition(e.g., in , on )is Chapter
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Web hosting e commerce - 200 . Chapter 12 ar[5] = “Friday” ar[6]

Thursday, September 27th, 2007

200 . Chapter 12 ar[5] = “Friday” ar[6] = “Saturday” var birthday = new Date(”January 3, 1978″) var day = birthday.getDay() alert(”You were born on ” + ar[day]) getHours() The getHours() function returns the number of hours since midnight. That is, it returns the current hour accordingto the 24-hour clock. Note that the range is 0-23, from midnight (0) to 11 P.M. (23). Here is an example: var now = new Date() var hour = now.getHours() var text = “” if (hour < 12) text = "morning" else if (hour < 16) text = "afternoon" else if (hour < 20) text = "evening" else text = "night" document.write("Good " + text + "!") This script segment prints a short greeting according to the time of the day. For example, if it is between 12:00 (noon) and 16:00 (4 P.M.), it prints Good afternoon! It is based on a nested if-else construct. getMinutes() The getMinutes() method returns the minute attribute of a Date instance. The integer returned is always from 0 to 59. Here is a short example to demonstrate the method: var now = new Date() var minute = now.getMinutes() var hour = now.getHours() var text = "Don't you have an appointment for " + (hour + 1) text += ":00 ?" if (minute > 49) document.write(text) At first, the message containing the nearest hour is built. For example, if it is currently 15:55, the message is built with the nearest hour, 16:00. The message is printed if the current time is less than ten minutes from the next hour. Note that if it is 23:59, the hour is presented as 24:00, not 00:00.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Time and (My web server) Date in JavaScript . 199 Figure12-5.

Thursday, September 27th, 2007

Time and Date in JavaScript . 199 Figure12-5. ExampleoutputusingthegetDate() method. This script segment combines all methods learned up to now to display a nicely formatted date. At first, all needed attributes of the previously created instance of the Date object are received and assigned to their corresponding variables (e.g., year, month, date). The last digit of the date (1-31) is then assigned to the variable lastDigit. Accordingto the value of lastDigit, the proper suffix is assigned to suf via a nested if-else statement. For the digit 1, the suffix is st (1st); for the digit 2, the suffix is nd (2nd); for the digit 3, it is rd (3rd); for all other digits, it is th (5th, 6th, …). Note that the last else statement associates the th suffix with all digits other than 1, 2, and 3. This suffix even applies to digits ending with a 0. An array of month names is created as before. The current date is then combined with its suffix to create a stringsuch as 27th. This string, alongwith all the other desired values, is used to build a complete date format, such as April 24th, 1997. The full stringis printed. getDay() This method returns the day of the week as an integer from 0 to 6. The day of the week is calculated accordingto the other attributes, so this method does not have a corresponding setDay() method. Here is an example: ar = new Array(7) ar[0] = “Sunday” ar[1] = “Monday” ar[2] = “Tuesday” ar[3] = “Wednesday” ar[4] = “Thursday” Chapter
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Web design seattle - 198 . Chapter 12 var exp = “”

Thursday, September 27th, 2007

198 . Chapter 12 var exp = “” // determine suffix if (lastDigit == 1) suf = “st” else if (lastDigit == 2) suf = “nd” else if (lastDigit == 3) suf = “rd” else suf = “th” // array for name of month var ar = new Array(12) ar[0] = “January” ar[1] = “February” ar[2] = “March” ar[3] = “April” ar[4] = “May” ar[5] = “June” ar[6] = “July” ar[7] = “August” ar[8] = “September” ar[9] = “October” ar[10] = “November” ar[11] = “December” var formDate = date + suf // build full date such as “May 5th, 1997″ var totalDate = ar[month]+”"+ formDate+ + year document.write(totalDate) The output for this script is shown in Figure 12-5:
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Windows 2003 server web - Time and Date in JavaScript . 197 Figure12-4.

Wednesday, September 26th, 2007

Time and Date in JavaScript . 197 Figure12-4. ExampleoutputusingthegetMonth() method. The current month is extracted from the now instance which holds the attributes of the current time (after the statement has executed). A static array is then created to hold all the names of the month (as strings), matchingeach name to its correspondingnumber in JavaScript, startingat zero. This obviously fits the default array structure, featuringthe first index as zero. Therefore, no math needs to be done, and the current month, by name, is used to construct a message, obviously a string. The message is then printed as plain HTML. . Warning: The getMonth attribute returns an incorrect value (off by one) on some older versions of Navigator. (MSIE works fine.) getDate() Called by a Date object, the getDate() method returns the date as an integer between 1 and 31. Here is an example: var now = new Date() var year = now.getYear() 12 var month = now.getMonth() var date = now.getDate() if (date < 10) var lastDigit = date else var lastDigit = date % 10 Chapter
We recommend high quality webhost to host and run your jsp application: christian web host services.