Tutorials » Javascript tutorials »

JavaScript Date object's getYear()


This article explains about JavaScript Date object's getYear() method


getYear()



returns current year or year of specified date if year is specified.




<html>

<head>

<script>

function f()

{

var date = new Date ()

alert("Specified Year is "+ date.getYear("August 15 , 2006 01:17:00"))

}

</script>

</head>

<body>

<input type ="button" value ="Click to get year " onclick ="return f();" >

</body>



As getYear() returns year out put is 2006

Note


getFullYear()Gets 4digits year ,where as getYear() returns 2 digits by default and depending on date specified it may return 4 digits too.



Next Chapter: Array object
Previous Chapter: Javascript date object's getMonth()
More Chapters: Javascript Tutorials
More Tutorials: Tutorial Index



Top Contributors
Today
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Omni Tech
    More...
     
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India