How Many Minutes Left Before Sunset


#1

Hi,

I want to use the “Fade Level” function of a dimmer light over ‘X’ minutes.

I have a boundary setup of 30 minutes before sunset to sunset

Depending on when I come home between that boundary, I just want the integer value of the time left until sunset.

So for instance, I come home 15 minutes before sunset…I want to be able to calculate and return the value of 15…so my lights will fade for 15 minutes to the level I want them to be until it’s sunset.

I’ve tried looking at the functions and I’ll admit I’m at a loss of how to do this and could use some help please. Thank you for your help in advance.


#2

Try…

round(($sunset - $now) / 1000 / 60 / 60)


#3

Thank you, I’ll give that a try.