getMinutes()We can extract or get the minute parts from the date object by using getMinutes() function.
The value will be from 0 to 59. Here is the simple code to get current minutes value.
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 valueAbove 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
The HTML part to show the SPAN tag with id, you can change the background color as per your requirement.
To initiate the timer function we have to add onload to our body tag.
The output of this code is here, keep watching for a minute and see how the time ( minutes part only) changes.
Using this concept we can display a real time changing CLOCK here.