Suppose you want to show a message to the user on the website or run any NodeJS job only when the time is between two hours of a day.
Date() object and take the appropriate action.
Date class will return the hours in military time using method
getHours() - 6 pm is represented as 18 in military time.
You could even extend this to minutes by using
getMinutes() method and further check if minutes are also in a specified range or not.