Copyright © tutorialspoint.com

Javascript Date getYear() Method

previous next

Advertisements


Description:

Javascript date getYear() method returns the year in the specified date according to universal time. The getYear is no longer used and has been replaced by the getFullYear method.

The value returned by getYear is the current year minus 1900. JavaScript 1.2 and earlier eturns either a 2-digit or 4-digit year, for example if the year is 2026, the value returned is 2026. So before testing this function make sure the version about the javascript version.

Syntax:

Date.getYear()

Here is the detail of parameters:

Return Value:

Returns the year in the specified date according to universal time.

Example:

<html>
<head>
<title>JavaScript getYear Method</title>
</head>
<body>
<script type="text/javascript">
   var dt = new Date();
   document.write("getYear() : " + dt.getYear() ); 
</script>
</body>
</html>

This will produce following result for the year 2008 :

getYear() : 208

To understand it in better way you can Try it yourself.


previous next

Copyright © tutorialspoint.com