C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date setMinutes() methodThe JavaScript date setMinutes() method is used to set the minutes for a specified date on the basis of local time. SyntaxThe setMinutes() method is represented by the following syntax: dateObj.setMinutes( minValue[, secValue[, msValue]]]) ParameterminValue - It represents an integer value between 0 and 59, specifying the minutes. If the provided minute value is greater than 59, the setMinutes() method increments the hour value accordingly. secValue ? It is optional. It represents an integer value between 0 and 59, specifying the seconds. If the provided second value is greater than 59, the setMinutes() method increments the minute value accordingly msValue ? It is optional. It represents an integer value between 0 and 999, specifying the milliseconds. If the provided millisecond value is greater than 999, the setMinutes() method increments the second value accordingly. JavaScript Date setMinutes() method exampleHere, we will understand setMinutes() method through various examples. Example 1Let's see an example to print current and updated minute value. <script> var minutes=new Date(); document.writeln("Current Minute : "+minutes.getMinutes()+"<br>"); minutes.setMinutes(32); document.writeln("Updated Minute : "+minutes.getMinutes()); </script> Output: Current Minute : 57 Updated Minute : 32 Example 2Let's see an example to update the minute value of the given time. <script> var minutes=new Date("August 15, 1947 20:22:10"); minutes.setMinutes(32); document.writeln("Updated Minute : "+minutes.getMinutes()); </script> Output: Updated Minute : 32 Example 3In this example, we will specify the seconds value (greater than 59) with the minutes. <script> var minutes=new Date("August 15, 1947 20:22:10"); minutes.setMinutes(22,62); document.writeln("Updated Minute : "+minutes.getMinutes()); </script> Output: Updated Minute : 23
Next TopicJavaScript Date
|