JavaScript valueOf() Method
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





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 |
|---|
JavaScript Date object