ES6 | Date

23 Oct, 2019
The ES6 Date is defined as the number of milliseconds that have been passed since midnight on January 1, 1970 UTC. Date objects can be created by the new Date() constructor. In JavaScript both date and time are represented by the Date object.
Constructors:
Date() – Create a date object for the current time and date.var date = new Date();
console.log(date);
Date(milliseconds) – Create a date object with time equal to the number of milliseconds passed from January 1, 1970 UTC.var date = new Date(1570991017113);
console.log(date);
Date(datestring) – Create a date object with the specified date string, then it is parsed automatically same as Date.parse() does.var date = new Date("2019-10-11");
console.log(date);
Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]) – Create a date object with the specified date in local time zone. The first two arguments are necessary and the rest are optional.var date = new Date(2019, 0, 11, 15, 45, 55, 55);
console.log(date);

Date() – Create a date object for the current time and date.var date = new Date();
console.log(date);

var date = new Date();
console.log(date);

Date(milliseconds) – Create a date object with time equal to the number of milliseconds passed from January 1, 1970 UTC.var date = new Date(1570991017113);
console.log(date);

var date = new Date(1570991017113);
console.log(date);

Date(datestring) – Create a date object with the specified date string, then it is parsed automatically same as Date.parse() does.var date = new Date("2019-10-11");
console.log(date);

var date = new Date("2019-10-11");
console.log(date);

Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]) – Create a date object with the specified date in local time zone. The first two arguments are necessary and the rest are optional.var date = new Date(2019, 0, 11, 15, 45, 55, 55);
console.log(date);

var date = new Date(2019, 0, 11, 15, 45, 55, 55);
console.log(date);

Properties:
Date.prototype: It represents the prototype for the Date constructor. Date.prototype is itself an ordinary object rather than the Date instance. It allows to add properties to the Date object.Date.constructor: It returns the reference of the array function that created the instance of the Date object.
Date.prototype: It represents the prototype for the Date constructor. Date.prototype is itself an ordinary object rather than the Date instance. It allows to add properties to the Date object.
Date.constructor: It returns the reference of the array function that created the instance of the Date object.
Methods:
Date.now(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.console.log(Date.now()); // 1571060400486 
// i.e. number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
Date.parse(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC for provided string representation of date.console.log(Date.parse("2019-10-11")); // 1570800633000
Date.UTC(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC for provided date separated by comma.console.log(Date.parse("2019, 9, 11")); // 1570800633000

Date.now(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.console.log(Date.now()); // 1571060400486 
// i.e. number of milliseconds elapsed since January 1, 1970 00:00:00 UTC

console.log(Date.now()); // 1571060400486 
// i.e. number of milliseconds elapsed since January 1, 1970 00:00:00 UTC

Date.parse(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC for provided string representation of date.console.log(Date.parse("2019-10-11")); // 1570800633000

console.log(Date.parse("2019-10-11")); // 1570800633000

Date.UTC(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC for provided date separated by comma.console.log(Date.parse("2019, 9, 11")); // 1570800633000

console.log(Date.parse("2019, 9, 11")); // 1570800633000

Date.prototype Methods:
getDate(): It returns the date of the month from the given date object.var d = new Date("2019-10-11");
console.log(d.getDate()); // 11
getDay(): It returns the day of the week from 0 to 6 according to local time of the given date object.var d = new Date("2019-10-11");
console.log(d.getDay()); // 5 i.e Friday
getFullYear(): It returns the full year of the given date object.var d = new Date("2019-10-11");
console.log(d.getFullYear()); // 2019
getHours(): It returns the hour (0-23) of the given date object.var d = new Date("2019-10-11 16:30:33");
console.log(d.getHours()); // 16
getMilliseconds(): It returns the milliseconds (0-999) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMilliseconds()); // 0
getMinutes(): It returns the minute (0-59) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMinutes()); // 30
getMonth(): It returns the month (0-11) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMonth()); // 9
getSeconds(): It returns the seconds (0-59) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getSeconds()); // 33
getTime(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTime()); // 1570791633000
getTimezoneOffset(): It returns the difference between UTC and local timezone in minutes.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTimezoneOffset()); // -330
getUTCDate(): It returns the day of the month (1-31) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDate()); // 11
getUTCDay(): It returns the day of the week (0-6) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDay()); // 5
getUTCFullYear(): It returns the year according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCFullYear()); // 2019
getUTCHours(): It returns the hour (0-23) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCHours()); // 11
getUTCMilliseconds(): It returns the milliseconds (0-999) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMilliseconds()); // 0
getUTCMinutes(): It returns the minutes according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMinutes()); // 0
getUTCMonth(): It returns the month (0-11) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMonth()); // 9
getUTCSeconds(): It returns seconds (0-59) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCSeconds()); // 33
setDate(): It is used to set the date of a month to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setDate(13);
console.log(d.getDate()); // 13
setFullYear(): It is used to set year to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setYear(2018);
console.log(d.getFullYear()); // 2018
setHours(): It is used to set hour (0-23) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setHours(19);
console.log(d.getHours()); // 19
setMilliseconds(): It is used to set milliseconds to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMilliseconds(200);
console.log(d.getMilliseconds()); // 200
setMinutes(): It is used to set minutes (0-59) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMinutes(20);
console.log(d.getMinutes()); // 20
setMonth(): It is used to set month (0-11) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMonth(8);
console.log(d.getMonth()); // 8
setSeconds(): It is used to set seconds (0-59) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setSeconds(34);
console.log(d.getSeconds()); // 34
setTime(): It is used to set milliseconds after January 1, 1970 00:00:00 UTC to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setTime(1570815753000);
console.log(d.toDateString()); // "Fri Oct 11 2019"
setUTCDate(): It is used to set date of the month (0-11) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCDate(12);
console.log(d.getDate()); // 12
setUTCFullYear(): It is used to set year to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCFullYear(2018);
console.log(d.getFullYear()); // 2018
setUTCHours(): It is used to set hours (0-23) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCHours(16);
console.log(d.getHours()); // 21
setUTCMilliseconds(): It is used to set milliseconds to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMilliseconds(166);
console.log(d.getMilliseconds()); // 166
setUTCMinutes(): It is used to set minutes (0-59) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMinutes(22);
console.log(d.getMinutes()); // 52
setUTCMonth(): It is used to set month (0-11) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMonth(8);
console.log(d.getMonth()); // 8
setUTCSeconds(): It is used to set seconds (0-59) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCSeconds(10);
console.log(d.getSeconds()); // 10

getDate(): It returns the date of the month from the given date object.var d = new Date("2019-10-11");
console.log(d.getDate()); // 11

var d = new Date("2019-10-11");
console.log(d.getDate()); // 11

getDay(): It returns the day of the week from 0 to 6 according to local time of the given date object.var d = new Date("2019-10-11");
console.log(d.getDay()); // 5 i.e Friday

var d = new Date("2019-10-11");
console.log(d.getDay()); // 5 i.e Friday

getFullYear(): It returns the full year of the given date object.var d = new Date("2019-10-11");
console.log(d.getFullYear()); // 2019

var d = new Date("2019-10-11");
console.log(d.getFullYear()); // 2019

getHours(): It returns the hour (0-23) of the given date object.var d = new Date("2019-10-11 16:30:33");
console.log(d.getHours()); // 16

var d = new Date("2019-10-11 16:30:33");
console.log(d.getHours()); // 16

getMilliseconds(): It returns the milliseconds (0-999) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMilliseconds()); // 0

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMilliseconds()); // 0

getMinutes(): It returns the minute (0-59) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMinutes()); // 30

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMinutes()); // 30

getMonth(): It returns the month (0-11) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMonth()); // 9

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getMonth()); // 9

getSeconds(): It returns the seconds (0-59) of the given date object according to the local time.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getSeconds()); // 33

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getSeconds()); // 33

getTime(): It returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTime()); // 1570791633000

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTime()); // 1570791633000

getTimezoneOffset(): It returns the difference between UTC and local timezone in minutes.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTimezoneOffset()); // -330

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getTimezoneOffset()); // -330

getUTCDate(): It returns the day of the month (1-31) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDate()); // 11

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDate()); // 11

getUTCDay(): It returns the day of the week (0-6) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDay()); // 5

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCDay()); // 5

getUTCFullYear(): It returns the year according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCFullYear()); // 2019

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCFullYear()); // 2019

getUTCHours(): It returns the hour (0-23) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCHours()); // 11

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCHours()); // 11

getUTCMilliseconds(): It returns the milliseconds (0-999) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMilliseconds()); // 0

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMilliseconds()); // 0

getUTCMinutes(): It returns the minutes according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMinutes()); // 0

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMinutes()); // 0

getUTCMonth(): It returns the month (0-11) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMonth()); // 9

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCMonth()); // 9

getUTCSeconds(): It returns seconds (0-59) according to universal time of the given date object.var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCSeconds()); // 33

var d = new Date("October 11, 2019 16:30:33");
console.log(d.getUTCSeconds()); // 33

setDate(): It is used to set the date of a month to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setDate(13);
console.log(d.getDate()); // 13

var d = new Date("October 11, 2019 16:30:33");
d.setDate(13);
console.log(d.getDate()); // 13

setFullYear(): It is used to set year to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setYear(2018);
console.log(d.getFullYear()); // 2018

var d = new Date("October 11, 2019 16:30:33");
d.setYear(2018);
console.log(d.getFullYear()); // 2018

setHours(): It is used to set hour (0-23) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setHours(19);
console.log(d.getHours()); // 19

var d = new Date("October 11, 2019 16:30:33");
d.setHours(19);
console.log(d.getHours()); // 19

setMilliseconds(): It is used to set milliseconds to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMilliseconds(200);
console.log(d.getMilliseconds()); // 200

var d = new Date("October 11, 2019 16:30:33");
d.setMilliseconds(200);
console.log(d.getMilliseconds()); // 200

setMinutes(): It is used to set minutes (0-59) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMinutes(20);
console.log(d.getMinutes()); // 20

var d = new Date("October 11, 2019 16:30:33");
d.setMinutes(20);
console.log(d.getMinutes()); // 20

setMonth(): It is used to set month (0-11) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setMonth(8);
console.log(d.getMonth()); // 8

var d = new Date("October 11, 2019 16:30:33");
d.setMonth(8);
console.log(d.getMonth()); // 8

setSeconds(): It is used to set seconds (0-59) to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setSeconds(34);
console.log(d.getSeconds()); // 34

var d = new Date("October 11, 2019 16:30:33");
d.setSeconds(34);
console.log(d.getSeconds()); // 34

setTime(): It is used to set milliseconds after January 1, 1970 00:00:00 UTC to the date object in local time.var d = new Date("October 11, 2019 16:30:33");
d.setTime(1570815753000);
console.log(d.toDateString()); // "Fri Oct 11 2019"

var d = new Date("October 11, 2019 16:30:33");
d.setTime(1570815753000);
console.log(d.toDateString()); // "Fri Oct 11 2019"

setUTCDate(): It is used to set date of the month (0-11) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCDate(12);
console.log(d.getDate()); // 12

var d = new Date("October 11, 2019 16:30:33");
d.setUTCDate(12);
console.log(d.getDate()); // 12

setUTCFullYear(): It is used to set year to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCFullYear(2018);
console.log(d.getFullYear()); // 2018

var d = new Date("October 11, 2019 16:30:33");
d.setUTCFullYear(2018);
console.log(d.getFullYear()); // 2018

setUTCHours(): It is used to set hours (0-23) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCHours(16);
console.log(d.getHours()); // 21

var d = new Date("October 11, 2019 16:30:33");
d.setUTCHours(16);
console.log(d.getHours()); // 21

setUTCMilliseconds(): It is used to set milliseconds to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMilliseconds(166);
console.log(d.getMilliseconds()); // 166

var d = new Date("October 11, 2019 16:30:33");
d.setUTCMilliseconds(166);
console.log(d.getMilliseconds()); // 166

setUTCMinutes(): It is used to set minutes (0-59) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMinutes(22);
console.log(d.getMinutes()); // 52

var d = new Date("October 11, 2019 16:30:33");
d.setUTCMinutes(22);
console.log(d.getMinutes()); // 52

setUTCMonth(): It is used to set month (0-11) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCMonth(8);
console.log(d.getMonth()); // 8

var d = new Date("October 11, 2019 16:30:33");
d.setUTCMonth(8);
console.log(d.getMonth()); // 8

setUTCSeconds(): It is used to set seconds (0-59) to the date object according to universal time.var d = new Date("October 11, 2019 16:30:33");
d.setUTCSeconds(10);
console.log(d.getSeconds()); // 10

var d = new Date("October 11, 2019 16:30:33");
d.setUTCSeconds(10);
console.log(d.getSeconds()); // 10

Date Conversion Methods:
toDateString(): It returns the string representation for the date portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toDateString()); // "Fri Oct 11 2019"
toISOString(): It returns the string representation for the date portion of the date object using ISO 8601 extended format.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toISOString()); // "2019-10-11T14:00:33.000Z"
toJSON(): It returns the string representation for the date portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toJSON()); // "2019-10-11T14:00:33.000Z"
toLocaleDateString(): It takes two parameters (optional) – locale and options and returns the string representation for the date portion according to specified locale.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleDateString()); // "10/11/2019"

// 10.2019
console.log(d.toLocaleDateString("de-DE", {year:'numeric', month: 'numeric'}))
toLocaleString(): It returns the string of date object of date portion in locale format.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleString()); // "10/11/2019, 7:30:33 PM"
toLocaleTimeString(): It returns the string representation for the time portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleTimeString()); // "7:30:33 PM"
toString(): It returns the string representation for date of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);

// "Fri Oct 11 2019 19:30:33 GMT+0530 (India Standard Time)"
console.log(d.toString()); 
toTimeString(): It returns the string representation for the time portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toTimeString()); // "19:30:33 GMT+0530 (India Standard Time)"
toUTCString(): It returns the string representation for the date object in format of universal timezone.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toUTCString()); // "Fri, 11 Oct 2019 14:00:33 GMT"
valueOf(): It returns the number of milliseconds elapsed from January 1, 1970 00:00:00 UTC to the date provided.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.valueOf()); // 1570802433000

toDateString(): It returns the string representation for the date portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toDateString()); // "Fri Oct 11 2019"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toDateString()); // "Fri Oct 11 2019"

toISOString(): It returns the string representation for the date portion of the date object using ISO 8601 extended format.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toISOString()); // "2019-10-11T14:00:33.000Z"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toISOString()); // "2019-10-11T14:00:33.000Z"

toJSON(): It returns the string representation for the date portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toJSON()); // "2019-10-11T14:00:33.000Z"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toJSON()); // "2019-10-11T14:00:33.000Z"

toLocaleDateString(): It takes two parameters (optional) – locale and options and returns the string representation for the date portion according to specified locale.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleDateString()); // "10/11/2019"

// 10.2019
console.log(d.toLocaleDateString("de-DE", {year:'numeric', month: 'numeric'}))

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleDateString()); // "10/11/2019"

// 10.2019
console.log(d.toLocaleDateString("de-DE", {year:'numeric', month: 'numeric'}))

toLocaleString(): It returns the string of date object of date portion in locale format.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleString()); // "10/11/2019, 7:30:33 PM"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleString()); // "10/11/2019, 7:30:33 PM"

toLocaleTimeString(): It returns the string representation for the time portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleTimeString()); // "7:30:33 PM"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toLocaleTimeString()); // "7:30:33 PM"

toString(): It returns the string representation for date of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);

// "Fri Oct 11 2019 19:30:33 GMT+0530 (India Standard Time)"
console.log(d.toString()); 

var d = new Date(2019, 9, 11, 19, 30, 33);

// "Fri Oct 11 2019 19:30:33 GMT+0530 (India Standard Time)"
console.log(d.toString()); 

toTimeString(): It returns the string representation for the time portion of the date object.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toTimeString()); // "19:30:33 GMT+0530 (India Standard Time)"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toTimeString()); // "19:30:33 GMT+0530 (India Standard Time)"

toUTCString(): It returns the string representation for the date object in format of universal timezone.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toUTCString()); // "Fri, 11 Oct 2019 14:00:33 GMT"

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.toUTCString()); // "Fri, 11 Oct 2019 14:00:33 GMT"

valueOf(): It returns the number of milliseconds elapsed from January 1, 1970 00:00:00 UTC to the date provided.var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.valueOf()); // 1570802433000

var d = new Date(2019, 9, 11, 19, 30, 33);
console.log(d.valueOf()); // 1570802433000

JavaScript-ES
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?