Skip to content

Instantly share code, notes, and snippets.

@Phally
Created April 7, 2013 20:18
Show Gist options
  • Save Phally/5332307 to your computer and use it in GitHub Desktop.
Save Phally/5332307 to your computer and use it in GitHub Desktop.
<?php
// Get solar minutes for seconds.
function solar($seconds) {
$leap = 365.25 / 365;
$inSeconds = $seconds * $leap;
$inMinutes = $inSeconds / 60;
return round($inMinutes);
}
// Get clock minutes for seconds.
function clock($seconds) {
$inSeconds = $seconds;
$inMinutes = $inSeconds / 60;
return round($inMinutes);
}
// Get length of solar/clock sync.
function getSync() {
$sec = 1;
while (solar($sec) == clock($sec)) {
$sec += 1;
}
return $sec;
}
$seconds = getSync();
$minutes = floor($seconds / 60);
echo "In sync for:" . PHP_EOL;
echo "- $seconds seconds" . PHP_EOL;
echo "- $minutes minutes" . PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment