Newer
Older
<!-- This example is from the book _JavaScript: The Definitive Guide_. -->
<!-- Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. -->
<!-- This example is provided WITHOUT WARRANTY either expressed or implied.-->
<!-- You may study, use, modify, and distribute it for any purpose. -->
<HTML>
<HEAD>
<TITLE>Today's Date</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// Define a function for use later on.
function print_todays_date()
{
var d = new Date(); // today's date and time.
document.write(d.toLocaleString());
}
</SCRIPT>
</HEAD>
<BODY>
<HR>The date and time are:<BR><B>
<SCRIPT LANGUAGE="JavaScript">
// now call the function we defined above
print_todays_date();
</SCRIPT>
</B><HR>
<!-- O'Reilly Footer Begins Here -->
<center>
</center>
<!-- O'Reilly Footer Ends Here -->
</BODY>
</HTML>