JavaScript valueOf()Method

Date 对象参考手册JavaScript Date Object

Example

Return the primitive value of a Date object:

var d=new Date();
var n=d.valueOf();

nOutput:


Try it Yourself »

Definition and Usage

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

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

valueOf() - All major browsers support the valueOf() method.


Syntax

Date.valueOf()

Return Value

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

Technical Details

JavaScript Version: 1.1


Date 对象参考手册JavaScript Date Object

Other Extensions