[Go to site: main page, start]

0% found this document useful (0 votes)
2 views1 page

JavaScript Date Functions

The document provides a detailed overview of the JavaScript Date Object, including methods for creating dates, retrieving date components, and formatting dates. It outlines various methods such as new Date(), getFullYear(), and toDateString(), along with their descriptions and examples. Important notes highlight that months are zero-based and clarify the difference between getDay() and getDate().

Uploaded by

srishtibhatt100
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

JavaScript Date Functions

The document provides a detailed overview of the JavaScript Date Object, including methods for creating dates, retrieving date components, and formatting dates. It outlines various methods such as new Date(), getFullYear(), and toDateString(), along with their descriptions and examples. Important notes highlight that months are zero-based and clarify the difference between getDay() and getDate().

Uploaded by

srishtibhatt100
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Date Object – Detailed Chart

1. Creating Date
Method Description Example
new Date() Current date and time new Date()
new Date(ms) From milliseconds since 1970 new Date(0)
new Date(dateString) From string new Date('2026-03-22')
new Date(y, m, d) Custom date new Date(2026, 2, 22)

2. Get Methods
Method Description
getFullYear() Returns year
getMonth() Returns month (0–11)
getDate() Returns day
getDay() Returns weekday (0–6)
getHours() Returns hours
getMinutes() Returns minutes
getSeconds() Returns seconds

3. Formatting Methods
Method Description
toDateString() Readable date
toTimeString() Full time
toLocaleDateString() Local date
toLocaleTimeString() Local time
toISOString() ISO format

Important Notes:
Months are zero-based (0 = January).
getDay() gives weekday, getDate() gives actual date.
Time format depends on system settings.

You might also like