Page 1 of 1

Sunrise / Sunset

Posted: Thu 30 Jan 2014 8:49 am
by captzero
Hi All,
I'm putting together a new webpage that's a little bit different. I'll have a webcam streaming a live image of an Australian Native Bee beehive (the bee's activity is dependent on whether its day or night, the current temperature and if its raining or not). I'll probably only have the camera streaming during the day. I'd like to display the time until sunrise and sunset, ie, 3 hours 30 mins to sunrise (not a countdown timer). Is this possible using the <#sunrise> and <#sunset> webtags or should I use the date_sunrise / date_sunset php functions?
Demo page is here
Thanks in advance.

Re: Sunrise / Sunset

Posted: Thu 30 Jan 2014 9:09 am
by beteljuice
If you are 'streaming' video (as opposed to a snapshot every x seconds) you don't want to keep refreshing your page (Unless perhaps you have current weather data on it).
So you would probably be better embedding one of the many 'coundown to an event' widgets which you set up with the sunset <#webtag>, or just code a JS timer to do the same thing.

Re: Sunrise / Sunset

Posted: Thu 30 Jan 2014 9:14 am
by mcrossley
Either solution is workable, either client side using some JavaScript or server side using PHP. The basic process for both would be to convert the current station time and sun rise/set times to native data-time objects, subtract one from the other to get the difference, display that value back in hours and minutes.

Re: Sunrise / Sunset

Posted: Thu 30 Jan 2014 9:25 am
by captzero
Thanks beteljuice, thanks Mark.
I'll see what I can come up with. I was able to display both the sunset and sunrise time with php using lon and lat and time offset and then wondered if I could use the cumulus tags instead. I'll probably go down the php path.
Thanks again.

Re: Sunrise / Sunset

Posted: Thu 30 Jan 2014 9:50 am
by mcrossley
Either way, personally I'd only display the message within a hour say of sun rise/set, it would be pretty meaningless around midday station time.