How to use setUTCMinutes in JavaScript
In this article, I will explain use of setUTCMinutes() method in JavaScript date object.
JavaScript setUTCMinutes() method
Syntax
Date.setUTCMinutes(min,sec,millisec)
|
-
Min : Min is optional parameter. An integer is representing the minutes and it's value between 0 and 59.
-
Sec : Sec is optional parameter. An integer is representing the seconds and it's value between 0 and 59,. If you given the secondsValue parameter, you must also give the minutesValue.
-
Mili : Mili is optional parameter. A number is representing the milliseconds and it's value between 0 and 999. If you give the Mili parameter, you must also give the Min and Sec.
Example
In the following example show to setUTCMinutes() method set the date time to be 30 minutes ago according to UTC.
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Orange ">JavaScript setUTCMinutes() Method Example</h3>
<p id="demo">Click for display the date after setting the time to be 30 minutes ago.</p>
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
function myFunction() {
var d = new Date();
d.setUTCMinutes(d.getUTCMinutes() - 30);
var x = document.getElementById("demo");
x.innerHTML ="30 minutes ago time is : "+ d;
}
</script>
</body>
</html>
|
Output1
Output2
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here