calculate the correct year of graduation
I need to filter by a user's class (whether they are a freshman, sophomore, etc.)
and I need a way to get their graduation year.My question is this: Given the current class (let's use freshmen for example),
come up with the correct graduation year (in the form yyyy).I was thinking it would have to check whether the current date was after Dec31,
and if it was, the seniors are the current year, and freshmen would be the current year - 4.Otherwise, seniors grad year would be the next year (current year + 1) and freshmen would be current year - 3.
Is there开发者_C百科 any easier or better way to do this?
AJreal,
You need to take into account that a freshman is a freshman from somewhere in august till as late as july the year after. From what I found on the internet it can vary from state to state. http://answers.yahoo.com/question/index?qid=20070819134832AA9yjTf
<?php
switch ($currentClass) {
case "Freshmen":
$currentMonth = date("m",time());
$currentYear = date("Y",time());
if (7 > $currentMonth < 12 ) {
$graduationYear = $currentYear + 4; # you can do a proper date time addition here creating a proper date as well
} else {
$graduationYear = $currentYear + 3; # you can do a proper date time addition here creating a proper date as well
}
break;
case "Senior":
break;
}
?>
精彩评论