|
| JAVASCRIPT getDate() METHOD
The getDate() method in javascript returns the day of the month as an integer from 1 to 31.
The general format is:
dateObject.getDate();
If you want to return the day of month with getDate() method, you will first have to create a new date object and then use the new date object with the getDate() method.
Example 1: Using getDate() for today's day of the month:
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd=dd.getDate(); // returns the day of month
doument.write(dd); // outputs the day of month
</script>
The above will output:
Example 2: Using getDate() for day of the month of specified date:
<script type="text/javascript">
var dd=new Date("December 16, 2005"); // creates a new date object
dd=dd.getDate(); // returns the day of month
doument.write(dd); // outputs the day of month
</script>
The above will output:
See Also:
|
|