Comparing Current Time with Input Time


(Dean) #1

I am looking for a way to compare the current time with a time the user enters as part of the input type time preferences. I see some examples of comparing the current time with sunset/sunrise using Weather Underground, but nothing to do a simple compare. Something like:

if current time > user specified time set mode to “Night-Away” else set mode to “Day-Away”

Thanks.


(Ronny Carr) #2

This is how it can be done:

//Create time of day vari. from user's input time
def timeOfDay = timeToday(usersTimeInput)
//if current time is equal to or after user's time
if(now() >= timeOfDay.time){
    //Do Something
}


(Dean) #3

Ronny, this was what I was looking for, thank you very much, I appreciate your help.