How to Add 1 h 40 m before sunset

This is the code for sunset time for current location:

$df(“hh:mm a”, ai(sunset))$

I want to add ‘1 hour and 40 minutes’ before sunset.

How to do that?

There’s probably more than one way to do this. What work for me is converting the time to epoc before any calculations. You can do something like:

$df(hh,mma, df(S, ai(sunset) - 6000))$

Basically, I converted ai(sunset) to epoc before subtracting 6000, which is the 1hr40mins, and then formatting it back to hhmma.

I hope that helps.

That is what I do as well, it works great and is easy to read!

1 Like

$if(ai(isday)=0,“Sunrise in”,“Sunset in”)$ $if(ai(isday)=0,mu(floor, tf(ai(nsunrise), M)/60)+ if(mu(floor, tf(ai(nsunrise), M)/60)>1, " “+hours,hour)+” “+tf(ai(nsunrise), M)%60,mu(floor, tf(ai(nsunset), M)/60)+” H "+tf(ai(nsunset), M)%60)$ Minutes

$df(“hh:mm a”, ai(sunset)-6000)$

Thanks a lot.
Its working perfectly

1 Like