f1sh3r Posted August 23, 2006 Share Posted August 23, 2006 im writing a function for a program im working on... there are a few different things it will do:1. get original price ($ofee) , and start date ($startdate) of a course2. if the price is > $99, offer an "early bird" price ($ofee - 20) if registered by 2 weeks prior ($startdate - 14 days)-- im good up to this point --3. if the class starts on a saturday or sunday, the "early bird" registration would need to be 15 or 16 days prior (on a friday) because office staff doesnt work weekendsmy choices? a) find what day (mon, tue, wed...) the class starts on, and act accordingly ($startdate - 15 or 16) b) have something that will only allow weekdays to be displayedc) ?help me out please... im not that good with time manipulation. thanks a bunch. Quote Link to comment Share on other sites More sharing options...
craygo Posted August 23, 2006 Share Posted August 23, 2006 I use the echo just to check the script. But this should do it.[code]$date = date(); //Need timestamp for other calculations$today = date("Y-m-d", $date); //formatted date$daylast = date("D", $date); // Get current day of the weekecho "Day of week: $daylast<br>";if($daylast == "Sat"){ $twoweek = strtotime("$today - 15 days");} else { if($daylast == "Sun"){ $twoweek = strtotime("$today - 16 days"); } else { $twoweek = strtotime("$today - 14 days"); }}$twoweeks = date("Y-m-d", $twoweek); //Formatted date of 2 weeks agoecho "Two Weeks: $twoweeks<br>";$daylast = date("D", $twoweek); //Just to check if correct can be removedecho "Day of week: $daylast<br>";[/code]Ray Quote Link to comment 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.