Dear friends, I need to produce just some dates from a whole year. I will provide numbers (0-6) from form submission. 0-6 means Numeric representation of the day of the week, Sunday to Saturday. Example: Input: $myDate = "3, 4, 6"; // Suppose I got this number form submitted form where it means Wednesday, Thursday & Saturday. $startDate = 10/03/2011 // mm-dd-yyyy $endDate = 10/02/2012 // mm-dd-yyyy (one year based on $startDate) Output: (it will generate dates for one year, I just show you some) 10/05/2011 Wednesday 10/06/2011 Thursday 10/08/2011 Saturday 10/12/2011 Wednesday 10/13/2011 Thursday 10/15/2011 Saturday ---- continue ----- 10/29/2011 Saturday 11/02/2011 Wednesday 11/03/2011 Thursday 11/05/2011 Saturday ---- continue ----- 09/26/2012 Wednesday 09/27/2012 Thursday 09/29/2012 Saturday Note: $myDate can be any value from 0 to 6. Suppose (0, 5) or (0, 1, 2, 3, 4) or (6) etc. any combination. You can reconstruct $myDate to keep the values according to your needs. Thank you.
Try this $days = explode(',',$myDate); foreach($days as $day){ $startday = time(); $endday = $startday + (3600 * 24 * 365); switch($day){ case 0: for($starttime=$startday; $starttime < $endday; $starttime += (3600 * 24)){ if(date('D', $starttime) === 'Sunday') echo date('m/d/Y D'); } // Repeat the same for each case break; case 1 : break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; } }
To honoring your time I will pay you a little amount $10.00 for this solution. Please don't mind as i have no ability to give you a handsome amount.