Welcome to the ExamAdda's Text Editor
Start creating amazing content with our feature-rich editor. You can format text, add images, create tables, and much more!
Use the toolbar above to format your content and create engaging articles.
When working with dates in JavaScript, you often need to extract parts of a date like year, month, day, or time.
For this, JavaScript provides Date get methods.
These methods help you read values from a Date object easily.
What Are Date Get Methods?
Date get methods are built-in functions that allow you to retrieve specific parts of a date, such as:
-
Year
-
Month
-
Day
-
Hours
-
Minutes
-
Seconds
They are commonly used in:
-
Clocks
-
Dashboards
-
Reports
-
Blogs
-
Booking systems
Creating a Date Object
This creates the current date and time.
Common Date Get Methods
Explanation (simple):
-
getFullYear()→ returns year (e.g., 2026) -
getMonth()→ returns month (0 = January) -
getDate()→ returns day of month -
getDay()→ returns weekday (0 = Sunday) -
getHours(),getMinutes(),getSeconds()→ time values
Example: Show a Simple Date
Output example:
Example: Show Current Time
Useful for:
-
Digital clocks
-
Activity logs
-
Live dashboards
Why Date Get Methods Are Important
Learning JavaScript date get methods helps you:
-
Display custom dates
-
Build time-based features
-
Handle API timestamps
-
Create real-world UI components
They are used in almost every professional project.
Quick Summary
-
getFullYear()→ year -
getMonth()→ month (0–11) -
getDate()→ day -
getDay()→ weekday -
getHours(),getMinutes(),getSeconds()→ time -
Always add
+1to month
Conclusion
Date get methods in JavaScript make it easy to extract and display date and time values. Once you understand these basics, working with calendars, clocks, and timestamps becomes very simple