Answer the question
In order to leave comments, you need to log in
How to determine the time interval on a node?
I'm trying to write a greenhouse lighting control in node.js.
I need to turn on the relay in the range from 22:00 to 6:00 and from 6:00 to 22:00 do not turn on the relay. I created two variables
var nightStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 22, 00, 00);
var dayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 06, 00, 00);
Answer the question
In order to leave comments, you need to log in
if (now < nightStart && now > dayStart){
//делаем то, что с 6:00 до 22:00
}else{
//делаем то, что с 22:00 до 6:00
}
Yuzai moment.js is the best library for working with time and dates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question