Get the primitive value of a date object:
const d = new Date();
let ms = d.valueOf();
Try it Yourself »
The valueOf() method returns the primitive value of a date object.
Note: The primitive value is returned as the number of millisecond since midnight January 1, 1970 UTC.
valueOf()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Date.valueOf()
None |
Return Value: | A Number, representing the number of milliseconds between the date object and midnight January 1, 1970 UTC |
---|---|
JavaScript Version: | ECMAScript 1 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!