Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:Date:valueOf

From MDC


Contents

[edit] Summary

Returns the primitive value of a Date object.

Method of Date
Implemented in: JavaScript 1.1
ECMA Version: ECMA-262

[edit] Syntax

valueOf()

[edit] Parameters

None.

[edit] Description

The valueOf method returns the primitive value of a Date object as a number data type, the number of milliseconds since midnight 01 January, 1970 UTC.

This method is functionally equivalent to the getTime method.

This method is usually called internally by JavaScript and not explicitly in code.

[edit] Examples

[edit] Example: Using valueOf

x = new Date(56, 6, 17);
myVar = x.valueOf();      //assigns -424713600000 to myVar


[edit] See also

Object.valueOf, getTime