Latest

recent

JavaScript toDateString() Method

Definition and Usage

The toDateString() method returns the date portion of a Date object in readable form.

Syntax

dateObject.toDateString()


Example 1

In the example below we will return the date portion of today's date:

<script type="text/javascript">
var d = new Date();
document.write(d.toDateString());
</script>

The output of the code above will be:

Fri May 11 2012


Example 2

In the example below we will return the date portion of a specific date:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00");
document.write(born.toDateString());
</script>

The output of the code above will be:

Thu Jul 21 1983
JavaScript toDateString() Method Reviewed by 1000sourcecodes on 02:53 Rating: 5
Powered by Blogger.