vkwd7 Posted October 26, 2008 Share Posted October 26, 2008 I am a newbie.I want to write a program for retirees on my web site in php.I am in a fix about certain date issues and seek help.for example we have 3 categories of pensioners (1) retired after 1-11-92 (2) after 1-11-97 (3) retred after 1-11-2002. they have different rates of allowances.I use '$DA_rate' for this.How to reflect say 1-11-1992 as a variabe and assign to it the value "1-11-1992"I tried using $dor = date("1-11-1992") and for others date of retriements, but the results are not as desired. I am enclosing a code also.I feel $dor= date("1/11/1997") is not the correct assignment because date() always gives current date.I need help. thanks. if($dor >= date("1/11/1997")) {$DA_rate=(89.28/100); } if($dor >= date("1/11/1992")) {$DA_rate=(117.78/100); } if($dor >= date("1/11/2002")) {$DA_rate=(39.78/100);} if($dor < date("1/11/1992")) {$DA_rate=(430.81/100); } $basic_pension=$Payable_basic_pension*3/2; $DA=$basic_pension*$DA_rate; function Gross_Pension ($Payable_basic_pension,$basic_pension,$DA, $dor) {$Gross_Pension=$Payable_basic_pension+$DA; return $Gross_Pension; echo"<b>My gross pension comes to :" ." " .($Gross_Pension) .(Gross_Pension($Payable_basic_pension,$basic_pension,$DA,$dor)) ."</b>";} ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/130155-dates-coding/ Share on other sites More sharing options...
Barand Posted October 26, 2008 Share Posted October 26, 2008 when using date time functions use ISO date format (2002-11-01). this also allows direct comparisons of date values Link to comment https://forums.phpfreaks.com/topic/130155-dates-coding/#findComment-674929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.