I've got a javascript widget on my page that outputs times for Sunrise and Sunset. The following code is what gets output (assume that these times change every day). I have no control over the output from the widget.
<div id="sun_container">
<div class="details">
Sunrise: <strong>7:00AM</strong> |
Sunset: <strong>4:30PM</strong>
</div>
</div>
Elsewhere on my page I have an image tag that looks like this:
<div id="sun_button">
<img src="images/day.png">
</div>
I want to parse out the sunrise time and the sunset time and compare these against the current server time (which I can output via PHP if necessary).
If the current server time is not between the sunrise and sunset times, then I want to change the image src
to "images/night.png"
.
Any ideas on how I could do this?
EDIT: I'm now outputting the server time in the page <head>
using:
var server_time = "<?=date("H:i:s", time())?>";
which outputs something like this:
var server_time = "17:07:41";