JavaScript getFullYear function is one of the Date Function, which returns the full year from a given date. We are using the JavaScript getFullYear to return the year (yyyy) from the current date and time.
<!DOCTYPE html> <html> <head> <title> JavaScript Get Full Year Function </title> </head> <body> <h1> JavaScript getFullYear Function Example </h1> <script> var dt = Date(); document.write("Date and Time : " + dt); document.write("Full Year from getFullYear(): " + dt.getFullYear()); </script> </body> </html>

JavaScript getFullYear Function Example
In this JavaScript get Full Year Function example, we are extracting the full year from the custom date
<!DOCTYPE html> <html> <head> <title> JavaScript Get Full Year Function </title> </head> <body> <h1> JavaScript getFullYear Function Example </h1> <script> var dt = Date("April 29, 2012 10:09:07"); document.write("Date and Time : " + dt); document.write("Full Year from getFullYear(): " + dt.getFullYear()); </script> </body> </html>

In this get Full Year example, we extract the year from the custom date without a year. This JavaScript getFullYear Function example will return the default year.
<!DOCTYPE html> <html> <head> <title> JavaScript Get Full Year Function </title> </head> <body> <h1> JavaScript getFullyear Function Example </h1> <script> var dt = Date("June 29 10:09:07"); document.write("Date and Time : " + dt); document.write("Full Year from getFullYear(): " + dt.getFullYear()); </script> </body> </html>
