Tutorials Point


  JavaScript Basics
  JavaScript Objects
  JavaScript Advanced
  JS Useful References
  JS Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Javascript Date setDate() Method


previous next AddThis Social Bookmark Button


Advertisements

Description:

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

Syntax:

Date.setDate( dayValue )

Here is the detail of parameters:

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

Return Value:

NA

Example:

The second statement below changes the day to Aug 24 from its original value.

<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>

This will produce following result :

Sun Aug 24 23:30:00 UTC+0530 2008 

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements