JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Date Right Arrow setMinutes()

setMinutes()  Date  instance method

Description

Sets the locale specific minute of the hour (0-59) for the specified date.

Syntax


Signature Description
aDate.setMinutes(minutesInt [, secondsInt[, millisecondsInt]])Sets the locale specific minute of the hour (0-59) for the specified date.

Parameters


Parameter Description
minutesIntAn integer in the range 0-59.
secondsIntAn integer in the range 0-59.
  • If secondsInt is not specified the value returned from the getSeconds() method is used.
millisecondsIntAn integer in the range 0-999.
  • If millisecondsInt not specified the value returned from the getMilliseconds() method is used.
  • If millisecondsInt is specified you must also specify secondsInt.
For specified values outside the ranges above the setMinutes() method will try and set the date accordingly.

Examples

The code below shows examples of the setMinutes() method of Date.


// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Set minutes.
todaysDate.setMinutes(45);
alert(todaysDate + ' - Minutes set to 45');
// Set minutes and seconds.
todaysDate.setMinutes(25,15);
alert(todaysDate + ' - Minutes and seconds set');

Press the button below to action the above code:


Related Tutorials

JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times



  

go to home page Homepage go to top of page Top