tekrscom Posted June 20, 2010 Share Posted June 20, 2010 Hi, I was wondering if someone could help me with this aggravating little problem I'm having... I feel like I am getting close, but as of yet, no cigar... So what I am trying to do is list all of the dates of the week, within a specified week... Here's what I got so far... The $_SESSION['SessionWeekEndingDate'] is in the standard yyyy-mm-dd format... <select name="DayOfWeek"> <? for ($i = 1; $i < 8 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]")); } foreach($myarray as $var) { echo '<option value="', $var, '">', $var, '</option>'; } ?> </select> Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/ Share on other sites More sharing options...
Mchl Posted June 20, 2010 Share Posted June 20, 2010 for ($i = 0; $i < 7 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") + 24 * 3600 * $i); } Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/#findComment-1074638 Share on other sites More sharing options...
tekrscom Posted June 20, 2010 Author Share Posted June 20, 2010 Thank you, that definately puts me on a better track than I was... the only problem now is that, that gives the dates after the $_SESSION['SessionWeekEndingDate'], instead of the dates prior to that date... for ($i = 0; $i < 7 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") + 24 * 3600 * $i); } Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/#findComment-1074639 Share on other sites More sharing options...
Mchl Posted June 20, 2010 Share Posted June 20, 2010 for ($i = 0; $i < 7 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") - 24 * 3600 * (7 - $i)); } [/cod Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/#findComment-1074642 Share on other sites More sharing options...
tekrscom Posted June 20, 2010 Author Share Posted June 20, 2010 Thank you... That worked very well,... Here's the final code... <select name="DayOfWeek"> <? for ($i = 0; $i < 7 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") - 24 * 3600 * (6 - $i)); } foreach($myarray as $var) { echo '<option value="', $var, '">', $var, '</option>'; } ?> </select> for ($i = 0; $i < 7 ;$i++) { $myarray[] = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") - 24 * 3600 * (7 - $i)); } [/cod Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/#findComment-1074652 Share on other sites More sharing options...
kenrbnsn Posted June 20, 2010 Share Posted June 20, 2010 Why use an array? Just use the data when you generate it: <select name="DayOfWeek"> <?php for ($i = 0; $i < 7 ;$i++) { $var = date("l, M j, Y", strtotime("$_SESSION[sessionWeekEndingDate]") - 24 * 3600 * (6 - $i)); echo '<option value="', $var, '">', $var, '</option>'; } ?> </select> Ken Link to comment https://forums.phpfreaks.com/topic/205324-array-of-dates-within-a-given-week/#findComment-1074654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.