Date.valueOf()

JavaScript1.1+, JScript3.0+, ECMAScript1.0+ NES2+, Nav3+, IE4+, Opera3+ Syntax

							date.valueOf()

Description

The valueOf() method returns the primitive value of the object. In terms of an instance of a Date object, this method returns the equivalence of the Date object in milliseconds. The milliseconds are expressed as an integer representing the number of milliseconds between midnight January 1, 1970 (GMT) to the date and time specified in the Date object.

Example

Listing 6.114 creates a Date object representing the current date and time. The result of the valueOf() method on this date object is displayed in the browser.

Listing 6.114 Using the valueOf() Method to Return the Value of the Date Object
 <script language="JavaScript"> ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.