Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object...
-
Upload
erika-stafford -
Category
Documents
-
view
228 -
download
0
Transcript of Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object...
![Page 1: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/1.jpg)
Extracting the System Date
Built-in Date() object Can be manipulated only by creating a new object instance
var variable = new object var birthDay = Date(“Jul, 13, 1975”)
Returns July 13, 1975 to birthDay var curDate = new Date()
Returns the current system date and time information as an object instance
![Page 2: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/2.jpg)
Extracting the System Date
The variable curDate cannot be manipulated
To extract the date, convert curDate to a string using the toLocaleString() and substring methods
![Page 3: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/3.jpg)
![Page 4: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/4.jpg)
Extracting the System Date
Define a new object for the date in MM/DD/YY HH:MM:SS format
var tNow = new Date()
Extract the date and time and store it in MM/DD/YY HH:MM:SS format
var tlocDate = tNow.toLocaleString()
Extract only the date portion from the tlocDate variable using relative addressing
var tDate = tlocDate.substring(0,10)
![Page 5: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/5.jpg)
Extracting the System Date
Relative addressing
![Page 6: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/6.jpg)
Extracting the Current System Date Using the Date() Object
Click the Notepad button on the taskbar to activate the Notepad window. Click line 19 below the document.bgColor=“blanchedalmond” statement
![Page 7: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/7.jpg)
Type var tNow = new Date() and thenpress the ENTER key. Type
var tlocDate = tNow.toLocaleString()and then press the ENTER key. Type
var tDate = tlocDate.substring(0,10)and then press the ENTER key
![Page 8: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/8.jpg)
![Page 9: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/9.jpg)
Displaying the Current System Date
Use plus signs (+) to concatenate (join) strings and variables
![Page 10: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/10.jpg)
Displaying the Current System Date in the Initial Greeting
Click line 22. Press the SPACEBAR four times. Type document.write(“<H2><CENTER>Welcome, today is “+tDate+”</CENTER></H2>”) and then press the ENTER key
![Page 11: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/11.jpg)
![Page 12: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/12.jpg)
Constructing a Message Using Several Variables
Click line 23. Type var intro1 = “Hi, thanks for visiting our Web site, but we have moved. Please make a note “ and then press the ENTER key
Type var intro2 = “of our new URL (www.funphonics.com) and notify the Webmaster about our new “ and then press the ENTER key
![Page 13: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/13.jpg)
Constructing a MessageUsing Several Variables
Type var intro3 = “location. Click<A Href=‘http://www.scsite.com/’>here</A> or wait 15 seconds “ and then press the ENTER key
Type var intro4 = “to be moved automatically to our new site.” and then press the ENTER key
![Page 14: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/14.jpg)
Constructing a MessageUsing Several Variables
Type var introMsg = intro1+intro2+intro3+intro4 and then press the ENTER key
![Page 15: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/15.jpg)
![Page 16: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/16.jpg)
Writing the Message on the Web Page
Click line 28. Press the SPACEBAR four times. Type document.write(“<H4><FONT Color=‘firebrick’>”+introMsg+”</H4></FONT>”) and then press the ENTER key
![Page 17: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/17.jpg)
![Page 18: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/18.jpg)
Saving a File
Save your file in your folder
![Page 19: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/19.jpg)
Click Save
![Page 20: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/20.jpg)
Testing the Web Page in the Browser
Click the Fun with Phonics button on the taskbar to activate the browser. Click the Refresh button on the browser toolbar
![Page 21: Extracting the System Date Built-in Date() object Can be manipulated only by creating a new object instance var variable = new object var birthDay.](https://reader036.fdocuments.us/reader036/viewer/2022062322/56649e4e5503460f94b4435e/html5/thumbnails/21.jpg)