JavaScript Date setDate() Method


Advertisements

Description

Javascript date setDate() method sets the day of the month for a specified date according to local time.

Syntax

Its syntax is as follows −

Date.setDate( dayValue )

Parameter Detail

dayValue − An integer from 1 to 31, representing the day of the month.

Example

Try the following example.

<html>
   <head>
      <title>JavaScript setDate Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date( "Aug 28, 2008 23:30:00" );
         dt.setDate( 24 );
         document.write( dt );
      </script>   
   </body>
</html>

Output

Sun Aug 24 2008 23:30:00 GMT+0530 (India Standard Time) 
javascript_date_object.htm
Advertisements