2011-08-10 8 views
0

ユーザーのクラスでフィルタリングする必要があります(新入生、二年生など)
と私は卒業年度を取得する方法が必要です。卒業の正確な年を計算する

私の質問はこれです:現在クラス(のは、例えば新入生を使用してみましょう)を考えると、
は(フォームYYYYで)正しい卒業年を思い付きます。

私は、それが現在の日付がDec31後だったかどうかを確認する必要があります考え
とそれがあった場合には、高齢者は現在の年であり、新入生は現在の年になりました - 4.

そうでない場合は、高等学校の卒業年は翌年(今年+ 1)、新入生は現在の年 - 3となります。

これを行うにはどのような方法がありますか?

+0

表示するコードはありますか? – afuzzyllama

答えて

0

AJreal、

あなたは新入生が遅けれ7月の翌年などまで、どこか8月中から新入生であることを考慮に入れる必要があります。私がインターネット上で見つけたことから、それは州ごとに異なる可能性があります。 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; 
} 

?> 
+0

Ajrealはこの質問を書いていないので、編集しました。 PumaのOP –

+0

もちろん、スイッチケースの外側にあるif(7> currentMonth <12)の部分をとり、変数名adjustYearを作り、-1または0の値を与えてcurrentYear + yearsToGraduation + adjustYearに追加することができます; –

関連する問題