.valueOf()
Anonymous contributor
Published Jul 22, 2021Updated May 31, 2023
Contribute to Docs
Returns the difference in milliseconds between the specified date and January 1, 1970 00:00:00 UTC.
Syntax
myDate.valueOf();
Example 1
Print the value of January, 1st, 1970 at 12:00:00 AM.
const date = new Date(1999, 00, 01, 0, 0, 0, 0);console.log(date);// Output: Fri Jan 01 1999 00:00:00 GMT-0800 (Pacific Standard Time)// Note: Timezone may varyconsole.log(date.valueOf());// Output: 915177600000
Codebyte Example
The following is runnable, and demonstrates the use of the .valueOf()
method.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.