Date.prototype.valueOf()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

valueOf() 함수는 Date 객체의 원시값을 반환합니다.

시도해보기

const date1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5));

console.log(date1.valueOf());
// Expected output: 823230245000

const date2 = new Date("02 Feb 1996 03:04:05 GMT");

console.log(date2.valueOf());
// Expected output: 823230245000

Syntax

js
dateObj.valueOf();

Return value

반환되는 milliseconds 값은 1 January 1970 00:00:00 UTC 와 주어진 일시 사이의 값입니다.

Description

valueOf() 함수는 01 January, 1970 UTC 이후의 milliseconds 단위의 자연수 타입인 Date 객체의 원시값을 반환합니다.

이 함수는 Date.prototype.getTime() 함수와 동일한 결과값을 반환합니다.

이 함수는 사용자 코드에 명시된 것이 아닌, JavaScript 자체에 포함되어 있습니다.

Examples

Using valueOf()

js
var x = new Date(56, 6, 17);
var myVar = x.valueOf(); // myVar에 -424713600000를 할당합니다.

명세서

Specification
ECMAScript® 2025 Language Specification
# sec-date.prototype.valueof

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
valueOf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also