Adding the Current Date and Time
Nothing makes your page seem more current than adding the date and the time. While they’re a bit more complicated to format in a particular way, just adding them is not difficult at all.
To add the current date and time to your page:
4. | In a separate text document, on the first line, type document.write(
|
5. | If desired, type "<tag>"+, where tag is the (X)HTML structure you’d like to apply to the date.
|
6. | Next type Date() to call JavaScript’s internal date function.
|
7. | If you’ve added an element in step 5, type +"<\/tag>", where tag is the corresponding closing tag. Notice the extra backslash that hides (X)HTML’s forward slash / from JavaScript.
|
8. |
Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.