![]() |
VOOZH | about |
The date.valueOf() method is used to get the number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.
dateObj.valueOf()This method does not accept any parameter. It is just used along with a Date object created using Date() constructor.
It returns the number of milliseconds between 1 January 1970 00:00:00 UTC and the given date as the contents of the Date() constructor.
Note: The DateObj is a valid Date object created using Date() constructor whose contents are used to get the number of milliseconds between 1 January 1970 00:00:00 UTC and the given date as the contents of the Date() constructor.
Example 1: This example shows the use of JavaScript Date valueOf() Method.
Output:
845337932000Example 2: If nothing as a parameter is passed while creating a date object but still the valueOf() method returns the number of milliseconds between 1 January 1970 00:00:00 UTC and the current date.
Output:
1524387231290Example 3: Date of a month ranging between 1 to 31. If the date is taken as 35 which is out of the date range, it returns NaN i.e, not a number.
Output:
NaNSome Important Points:
We have a complete list of Javascript Date Objects, to check those please go through this article.