| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since 20157.
Date valueOf() UTC 1970 1 1
const date1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5));
console.log(date1.valueOf());
// 823230245000
const date2 = new Date("02 Feb 1996 03:04:05 GMT");
console.log(date2.valueOf());
// 823230245000
valueOf()
valueOf() Date [Symbol.toPrimitive]() Date valueOf()Date.prototype[Symbol.toPrimitive]() this.valueOf()
Date Object valueOf() Date.prototype.valueOf() Date.prototype.getTime()
const d = new Date(0); // 1970-01-01T00:00:00.000Z
console.log(d.valueOf()); // 0
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-date.prototype.valueof |
This page was last modified on 2025818 by MDN contributors.
DategetDate()Date.prototype.getDay()getFullYear()Date.prototype.getHours()Date.prototype.getMilliseconds()Date.prototype.getMinutes()getMonth()Date.prototype.getSeconds()Date.prototype.getTime()getTimezoneOffset()getUTCDate()getUTCDay()getUTCFullYear()Date.prototype.getUTCHours()Date.prototype.getUTCMilliseconds()Date.prototype.getUTCMinutes()getUTCMonth()Date.prototype.getUTCSeconds()getYear()setDate()setFullYear()Date.prototype.setHours()setMilliseconds()setMinutes()setMonth()setSeconds()Date.prototype.setTime()setUTCDate()setUTCFullYear()Date.prototype.setUTCHours()setUTCMilliseconds()setUTCMinutes()setUTCMonth()setUTCSeconds()setYear()toDateString()toISOString()toJSON()toLocaleDateString()toLocaleString()toLocaleTimeString()toString()toTemporalInstant()toTimeString()toUTCString()valueOf()[Symbol.toPrimitive]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |