Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript valueOf() Method

JavaScript valueOf() Method

Date Object Reference JavaScript Date object

Example

Returns the primitive value of a Date object:

var d=new Date();

var n=d.valueOf();

n Output result:

Try it »


Definition and Usage

The valueOf() method returns the primitive value of a Date object.

**Note:** The primitive value returned is the number of milliseconds since midnight, January 1, 1970!


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the valueOf() method


Syntax

Date

.valueOf()

Return Value

Type Description
Number The millisecond representation of the date. The return value equals the value returned by the method Date.getTime, returning the number of milliseconds since midnight, January 1, 1970. /td>

Technical Details

JavaScript version: 1.1

Date Object Reference JavaScript Date object