We can extract or get the minute parts from the date object by using getMinutes() function.
<script>
var DateObj = new Date('September 21, 2018 05:35:32');
var minutes = DateObj.getMinutes();
document.write(minutes); // output is 35
</script>
The value will be from 0 to 59. Here is the simple code to get current minutes value.
var dt= new Date();
document.write(dt.getMinutes());
Here is the output based on your time zone and date and time of your computer
We will get minutes from this date object. We can further work on this minutes part and set it to previous or advance value by using setMinutes function.
Displaying changing minutes value
Above display of minute shows the value at the time of page loading. To display real time or changing minutes we have to run this code again after an interval. For this we will use the setTimeout function.
Here is the code to keep inside HEAD tag of the page
<script>
function timer(){
var dt= new Date();
document.getElementById(\"d1\").innerHTML = dt.getMinutes();
setTimeout('timer()',1000);
}
</script>
The HTML part to show the SPAN tag with id, you can change the background color as per your requirement.