JavaScript Reference/Javascript Methods/getYear

Материал из Web эксперт
Перейти к: навигация, поиск

"getYear()" Example

   <source lang="javascript">
   

<html> <body> <button onclick="var myDate = new Date(); alert(myDate.getYear());">get year</button> </body> </html>


     </source>
   
  


"getYear()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |Date | +----------------+--------------------------------------------------------------+

     </source>
   
  


"getYear()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Returns the year. When the year is before 2000, the return value is the year minus 1900. When the year is 2000 or after, the return value is the four-digit year.

Syntax:

dateName.getYear()


     </source>