In this tutorial, we will learn Date in JavaScript. JavaScript Date method helps us to do various basic functions like to get the current date, time and year. We can also add timers on the Web pages with the help of the date object. Date object provides us with four types of constructors we can use any according to our requirement to create an object of Date. It also has a lot of methods which we will read in this tutorial.
Firstly we will check constructors which are available to us to create an object of Date.
- Date()
- Date(milliseconds)
- Date(dateString)
- Date(year, month, day, hours, minutes, seconds, milliseconds)
Methods of Date:
There is great collection of methods available in Date Object. Check the following table.
| Method | Description |
|---|---|
| getDate() | This method would return current according to local time. |
| getDay() | It returns the integer value between 0 and 6 that represents the day of the week on the basis of local time. |
| getFullYears() | It returns the integer value that represents the year on the basis of local time. |
| getHours() | It returns the integer value between 0 and 23 that represents the hours on the basis of local time. |
| getMilliseconds() | It returns the integer value between 0 and 999 that represents the milliseconds on the basis of local time. |
| getMinutes() | It returns the integer value between 0 and 59 that represents the minutes on the basis of local time. |
| getMonth() | It returns the integer value between 0 and 11 that represents the month on the basis of local time. |
| getSeconds() | It returns the integer value between 0 and 60 that represents the seconds on the basis of local time. |
| setDate() | It sets the day value for the specified date on the basis of local time. |
| setDay() | It sets the particular day of the week on the basis of local time. |
| setFullYears() | It sets the year value for the specified date on the basis of local time. |
| setHours() | It sets the hour value for the specified date on the basis of local time. |
| setMilliseconds() | It sets the millisecond value for the specified date on the basis of local time. |
| setMinutes() | It sets the minute value for the specified date on the basis of local time. |
| setMonth() | It sets the month value for the specified date on the basis of local time. |
| setSeconds() | It sets the second value for the specified date on the basis of local time. |
Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
