extracting the system date built-in date() object can be manipulated only by creating a new object...

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 = 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

Upload: erika-stafford

Post on 11-Jan-2016

231 views

Category:

Documents


0 download

TRANSCRIPT

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

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

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
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

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

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

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

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
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

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

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
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

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

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

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
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

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
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

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

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

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