If the hour is less than 10 hours the hours are usually placed in single digit form.
var currentHours = currentTime.getHours ( );
Is the following the only best way to get the hours to display as 09
instead of 9
?
if (currentHours < 10) currentHours = '0'+currentHours;
You can't do much better. Maybe you'll like:
Your's method is good. Also take a note of it
You can do this using below code,
create function,
and then use it as below,