-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtagnacht.php
27 lines (23 loc) · 852 Bytes
/
tagnacht.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
$imageDay = 'tag.jpg';
$imageNight = 'nacht.jpg';
$lat = 50.83594;
$lon = 12.92330;
$timeZone = new DateTimeZone('Europe/Berlin');
$sunRise = date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $lon);
$sunSet = date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $lon);
$sunRise = DateTime::createFromFormat('Y-m-d H:i', date('Y-m-d ') . $sunRise);
$sunSet = DateTime::createFromFormat('Y-m-d H:i', date('Y-m-d ') . $sunSet);
$sunRise->setTimezone($timeZone);
$sunSet->setTimezone($timeZone);
$now = new DateTime();
$now->setTimezone($timeZone);
$image = $imageNight;
if ($now >= $sunRise && $now <= $sunSet) {
$image = $imageDay;
}
header("Content-type: image/jpeg");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
readfile($image);