|
| JAVASCRIPT setMinutes() METHOD
The setMinutes() method in javascript returns the date and time by setting the minutes. Takes a compulsory minute argument as a number from 0 to 59, an optional seconds argument as a number from 0 to 59 and an optional millisecond argument as a number from 0 to 1000.
Any optional arguments not supplied will take default values of the current time of user's computer.
The general format is:
dateObject.setMinutes(minutes, seconds[optional], milliseconds[optional]);
If you want to return the full date and time with the setMinutes() method, you will first have to create a new date object and then use the new date object with the setMinutes() method.
Example 1: With only the minute supplied
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd.setMinutes(48); // sets the date
document.write(dd); // outputs the date
</script>
The above will output:
Example 2: With all parameters supplied
<script type="text/javascript">
var dd=new Date(); // creates a new date object
dd.setMinutes(24, 37, 345); // sets the date
document.write(dd); // outputs the date
</script>
The above will output:
See Also:
|
|