valueOf()  Date  instance method JS Home  <<  JS Reference  <<  Date  <<  valueOf()

Description

Returns the primitive value of a Date object.

This method overrides the valueOf() method of Object.

Syntax

Signature Description
aDate.valueOf()Returns the primitive value of a Date object.

Parameters

None.

Examples

The code below shows an example of the valueOf() method of Date.



// Create a Date instance for the current date and time.
var todaysDate = new Date();

alert(todaysDate);
alert(todaysDate.valueOf() + ' Primitive value of a Date object');

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times