Theme Layout

Boxed or Wide or Framed

Wide

Theme Translation

Display Featured Slider

Featured Slider Styles

Display Grid Slider

yes

Grid Slider Styles

Display Trending Posts

Display Author Bio

Display Instagram Footer

off

Dark or Light Style

Light

Blog Archive

Powered by Blogger.

Thursday, February 16, 2017

[JavaScript] Date Methods


# 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

QuickEdit
Unknown
0 Comments
Share This Post :

You Might Also Like

No comments:

Post a Comment

Follow @SunriseSunsetBlog