# JavaScript Date Methods
● Date Get Methods
Get Methods are used for getting a part of a date. Here are most common.
https://www.w3schools.com/js/js_date_methods.asp |
● Date getTime() Method
getTime() returns the number of milliseconds since Jan 1,1970.
● Date getFullYear() Method
getFullYear() returns the year of a date as a four digit number.
● The getDay() Method
getDay() returns the weekday as a number ( 0 - 6 ).
In JSP, the first day of the week (0) means "Sunday".
● Date Set Methods
Set methods are used for setting a part of a date. Here are the most common.
https://www.w3schools.com/js/js_date_methods.asp |
● The setFullYear() Method
setFullYear() sets a date object to a specific date.
● The setDate() Method
setDate() sets the day of the month (1-31)
The setDate() method can also be used to add days to a date.
● Date Input - Parsing Dates
When I have a valid date string, I can use the Date.parse() method to convert it to milliseconds. Date.parse() returns the number of milliseconds between the date and Jan 1, 1970.
and then, use the number of milliseconds to convert it to a date object.
● Compare Dates
Dates can easily be compared.
The following example compares today's date with Feb 19, 1994.
● UTC Date Methods
UTC date methods are used for working UTC dates
https://www.w3schools.com/js/js_date_methods.asp |
No comments:
Post a Comment