How to use the Unary Plus Operator (+) In Javascript
You can also convert a Date object to a Number using the unary plus operator (+). When applied to a Date object, it coerces the Date object into its equivalent numeric value, which represents the number of milliseconds since the epoch (January 1, 1970).
// JavaScript Program to Convert Date to Number
const date = new Date('May 19, 2000 12:10:52');
console.log(+date);
Output
958738252000
JavaScript Program to Convert Date to Number
This article will explain how to convert a Date into a Number using JavaScript. The JavaScript Date object is used to get dates and times. It helps in formatting the dates. We can use the new keyword to create an object for Date. To convert a Date to a Number, we use the getTime() method.