- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the only current year in JavaScript?
To get an only current year, use the JavaScript getFullYear() method. JavaScript date getFullYear() method returns the year of the specified date according to local time. The value returned by getFullYear() is an absolute number. For dates between the years 1000 and 9999, getFullYear() returns a four-digit number, for example, 2008.
Example
You can try to run the following code to get a current year in JavaScript −
<html> <head> <title>JavaScript getFullYear Method</title> </head> <body> <script> var dt = new Date("December 30, 2017 23:15:00"); document.write("getFullYear() : " + dt.getFullYear() ); </script> </body> </html>
Output
getFullYear() : 2017
- Related Articles
- How to display only the current year in JavaScript?
- How to get the current year in JavaScript?
- How to print current year in JavaScript?
- How to get current day, month and year in Java 8?
- Get the days remaining in current year in Java
- Get current year in MySQL WHERE clause?
- How to get current URL in JavaScript?
- How to get the current URL with JavaScript?
- Java Program to get current date, year and month
- MySQL query to get current datetime and only current date
- How to check Leap Year in Java 8 How to get current timestamp in Java 8?
- How to get the current time in millisecond using JavaScript?
- How to get current date and time in JavaScript?
- How do I get the current date in JavaScript?
- How to get current date/time in seconds in JavaScript?

Advertisements