JavaScript tutorial:
getDate method

 

Applies to: Date Object

The getDate method is use to get the day of the month value in a Date object using local time.

Syntax

objDate.getDate()

Return date

Returns the day of the month value in a Date object using local time.

Example

To get the date value using Universal Coordinated Time (UTC), use the getUTCDate method.

The return value is an integer between 1 and 31 that represents the date value in the Date object.

The following example illustrates the use of the getDate method:

s = "Today's date is: ";
d = new Date();
s += (d.getMonth() + 1) + "/";
s += d.getDate() + "/";
s += d.getYear();

document.write(s);

  To run the code above, paste it into JavaScript Editor, and click the Execute button

See also: Date Object Methods, getUTCDate Method, setDate Method, etUTCDate Method