Created
March 31, 2017 21:22
-
-
Save dennisheitmann/b58d6b4c52ba330145151778a355e9cb to your computer and use it in GitHub Desktop.
Sunrise and sunset at given coordinates (PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$lat = 47.85; | |
$lon = 12.55; | |
if (isset($argv[1])) { | |
$sun = $argv[1]; | |
} else { | |
$sun = ""; | |
} | |
switch ($sun) { | |
case "sunrise": | |
echo date_sunrise(time(), SUNFUNCS_RET_STRING, $lat, $lon, 90, 0); | |
echo "\n"; | |
break; | |
case "sunset": | |
echo date_sunset(time(), SUNFUNCS_RET_STRING, $lat, $lon, 90, 0); | |
echo "\n"; | |
break; | |
default: | |
echo $argv[0]." (sunrise|sunset)"; | |
echo "\n"; | |
echo "Output time in UTC"; | |
echo "\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment