The Date Object
The Date object offers you a wealth of date-related properties and methods.
To use the Date object, the first thing you must do is to assign it a variable name (similar to how you use the Array object):
<script language="JavaScript"> <!-- Cloaking device on! dateVar = new Date(); // Cloaking device off --> </script>
Now that you have done this, you can start to use the Date object.
NOTE
Using new Date() with no arguments returns the current date and time to which the system is set.
NOTE
The range of dates that can be represented in a Date object is approximately 285,616 years on either side of January 1, 1970!
Using the getFullYear Method
The first thing you can try out is retrieving the full year using the getFullYear method ...
Get JavaScript™ 1.5 by Example 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.