vbcoach Posted April 21, 2011 Share Posted April 21, 2011 Hello all. Trying this again. I would like to implement a simple math formula based on a date, but not sure how to do that exactly. I run a sports league, and want to calculate fees based upon a fixed date. Prior to 'some date' use this calculation, but after this date, add late fees using 2nd calculation. In my code there are two fields: $earlyteam and $lateteam. I need $lateteam to kick in after 'some date'. Help? //calculate Fees $size = $lSize['size']; switch($size) { case 2: $base = 150; $size = 3; break; case 4: $base = 330; $size = 6; break; case 6: $base = 550; $size = 10; break; default: die ("invalid league size"); }; $earlyTeam = $base; { $e_each = $earlyTeam / $pCount; $lateTeam = $earlyTeam * 1.10; $l_each = $lateTeam / $pCount; } Quote Link to comment https://forums.phpfreaks.com/topic/234352-using-date-in-math-formula/ Share on other sites More sharing options...
Muddy_Funster Posted April 21, 2011 Share Posted April 21, 2011 I don't see anything in there that has to do with dates, I don't understand what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/234352-using-date-in-math-formula/#findComment-1204501 Share on other sites More sharing options...
PFMaBiSmAd Posted April 21, 2011 Share Posted April 21, 2011 You can use greater-than/less-than/equal comparisons on dates if the fields making up the date are from left-to-right, most significant field (year) to least significant field (day). YYYY-MM-DD is a commonly used format that will work. Quote Link to comment https://forums.phpfreaks.com/topic/234352-using-date-in-math-formula/#findComment-1204503 Share on other sites More sharing options...
vbcoach Posted April 21, 2011 Author Share Posted April 21, 2011 So I can just use $lateteam = '04/21/2011' and this will work? Quote Link to comment https://forums.phpfreaks.com/topic/234352-using-date-in-math-formula/#findComment-1204512 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.