Created
September 24, 2014 06:16
-
-
Save nachopants/3b8a9fd27ee0d63fb65e to your computer and use it in GitHub Desktop.
Preservation Age
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
<?php | |
/* | |
Date of Birth - Preservation Age | |
Before 1 July 1960 - 55 | |
1 July 1960 to 30 June 1961 - 56 | |
1 July 1961 to 30 June 1962 - 57 | |
1 July 1962 to 30 June 1963 - 58 | |
1 July 1963 to 30 June 1964 - 59 | |
After 30 June 1964 - 60 | |
*/ | |
if (($ts = strtotime($dateOfBirth)) !== false) | |
{ | |
$age = 55; | |
$preservationAge = 60; | |
for ($year = 1960; $year < 1965; $year++) | |
{ | |
$min = strtotime('1 July ' . $year); | |
$max = strtotime('+1 year', $min); | |
($ts < $min && $year == 1960 || ($ts >= $min && $ts < $max)) ? $preservationAge = $age : $age++; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment