JavaScript Date prototype Property

The date.prototype property represents the prototype for the Date constructor. The prototype allows adding new properties, and methods.
Below are examples of Date prototype Property.
Example:
javascript
| varbirthday = newDate('June 21, 2018 16:44:23');vardate1 = birthday.getDate(); varday1 = birthday.getDay(); varyear1 = birthday.getFullYear(); varhour1 = birthday.getHours(); varms1 = birthday.getMilliseconds(); varm1 = birthday.getMinutes(); varmth1 = birthday.getMonth(); vartime1 = birthday.getTime(); vars1 = birthday.getSeconds(); varoffset = birthday.getTimezoneOffset(); vardate2 = birthday.getUTCDate(); varday2 = birthday.getUTCDay(); varyear2 = birthday.getUTCFullYear(); varhour2 = birthday.getUTCHours(); varms2 = birthday.getUTCMilliseconds();varum1 = birthday.getUTCMinutes();varumth = birthday.getUTCMonth();varus = birthday.getUTCSeconds();console.log(date1);console.log(day1);console.log(year1);console.log(hour1);console.log(ms1);console.log(m1);console.log(mth1);console.log(time1);console.log(s1);console.log(offset);console.log(date2);console.log(day2);console.log(year2);console.log(hour2);console.log(ms2);console.log(um1);console.log(umth);console.log(us);         | 
Output:
21 4 2018 16 0 44 5 1529579663000 23 -330 21 4 2018 11 0 14 5 23
It has the following methods:
- getDate():This method will return the day of the month for the specified date according to the local time.
- getDay():This method will return the day of the week (0 for Sunday and 6 for Saturday) for the specified date according to the local time.
- getFullYear(): It returns the year for the specified date according to local time.
- getHours(): It returns the hour(0-23) for the specified date according to local time.
- getMilliseconds: It returns the milliseconds (0-999) for the specified date according to local time.
- getMinutes(): It returns the minutes (0-59) for the specified date according to local time.
- getMonth(): It returns the month (0-11) for the specified date according to local time.
- getSeconds(): It returns the seconds(0-59) for the specified date according to local time.
- getTime(): It returns the number of milliseconds elapsed since January 01, 1970 00:00:00 UTC. It is negative for time 
 before the given time.
- getTimezoneOffset(): It returns the timezone offset in minutes for current location.
- getUTCDate(): It returns the date of the month (1-31) for the specified date according to universal time.
- getUTCDay(): It returns the day of the week (0-6) for the specified date according to universal time.
- getUTCFullYear(): It returns the year for the specified date according to universal time.
- getUTCHours(): It returns the hours (0-23) for the specified date according to universal time.
- getUTCMilliseconds(): It returns the milliseconds(0-999) for the specified date according to universal time.
- getUTCMinutes(): It returns the minutes (0-59) for the specified date according to universal time.
- getUTCMonth(): It returns the month (0-11) for the specified date according to universal time.
- getUTCSeconds(): It returns the seconds (0-59) for the specified date according to universal time.
It also has some other methods which can be used to convert the date to different formats:
- toDateString(): Returns the “date” portion of the Date as a human-readable string.
- toGMTString(): Returns a string representing the Date based on the GMT (UT) time zone.
- toLocaleFormat(): Converts a date to a string, using a format string.
- toLocalestring(): Returns a string with a locality-sensitive representation of this date.
- toString(): Returns a string representing the specified Date object.
- toTimeString(): Returns the “time” portion of the Date as a human-readable string.
- valueOf(): Returns the primitive value of a Date object.
We have a complete list of Javascript Date Objects, to check those please go through this Javascript Date Object Complete reference article.
Supported Browsers: The browsers supported by JavaScript Date prototype Property are listed below:
- Google Chrome
- Internet Explorer
- Mozilla Firefox
- Opera
- Safari
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
 
				 
					


