jvrothjr Posted January 5, 2012 Share Posted January 5, 2012 I am having some issues with getting dates for the days of the week based on one date givin Example: User enters date for sunday. (Ending pay period) and I wish to get the dates for that week. Mon - 1-2-2012 Tue - 1-3-2012 Wed - 1-4-2012 Thu - 1-5-2012 Fri - 1-6-2012 Sat - 1-7-2012 Sun - 1-8-2012 User would enter 1/8/2012 and the script would get the rest of the dates to enter into the timecard. I have tried both ways below and cant get it to work no mater if i change the user input date i still get the same output. Function getdatepast($dtp,$cnt) { $undatecon = mktime($dtp); $undatecon2 = strtotime("-".$cnt." day", $undatecon); $ddt1 = date('m-d-Y',($undatecon2)); return $ddt1; } Function getdatepast($dtp,$cnt) { $undatecon = mktime($dtp); $undatecon2 = $undatecon - (86400 * ($cnt)); $ddt1 = date('m-d-Y',($undatecon2)); return $ddt1; } Quote Link to comment https://forums.phpfreaks.com/topic/254417-date-generator/ Share on other sites More sharing options...
litebearer Posted January 5, 2012 Share Posted January 5, 2012 just a rough idea - modify as needed <?PHP $date = "01/13/2012"; /* your given date in mm/dd/yyyy format */ for($i=1;$i<8;$i++) { $date2 = date (' m/d/Y' , (strtotime ( '+1 day' , strtotime ( $date ) )) ); echo date (' l' , (strtotime ( '+1 day' , strtotime ( $date ) ) ) ) . " - " . $date2 . "<br/>"; $date = $date2; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/254417-date-generator/#findComment-1304539 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.