Open In App

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:  




var birthday = new Date('June 21, 2018 16:44:23');
var date1 = birthday.getDate();
var day1 = birthday.getDay();
var year1 = birthday.getFullYear();
var hour1 = birthday.getHours();
var ms1 = birthday.getMilliseconds();
var m1 = birthday.getMinutes();
var mth1 = birthday.getMonth();
var time1 = birthday.getTime();
var s1 = birthday.getSeconds();
var offset = birthday.getTimezoneOffset();
var date2 = birthday.getUTCDate();
var day2 = birthday.getUTCDay();
var year2 = birthday.getUTCFullYear();
var hour2 = birthday.getUTCHours();
var ms2 = birthday.getUTCMilliseconds();
var um1 = birthday.getUTCMinutes();
var umth = birthday.getUTCMonth();
var us = 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:

It also has some other methods which can be used to convert the date to different formats: 

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:

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.


Article Tags :