redarrow Posted February 1, 2007 Share Posted February 1, 2007 How do i get a loop to show the date from date start to date end showing all dates avalable example <?php //get todays date $date_start=date("d-m-y"); //get todays date in a timestamp $date_start=strtotime($date_start); //make a timestamp and date to stop by $date_end= mktime(0, 0, 0, date("d")+7 , date("m"), date("Y")); //some for loop to get the start date to end date showing all dates //format the date result from the loop $date_result=date("y-m-d",$result); //echo the dates echo $date_result; ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted February 1, 2007 Share Posted February 1, 2007 I would probably start with date_start, and use mktime() to add 1 day until you reach date_end. You can also add 60*60*24 seconds, but apparently that may cause trouble during daylight savings switchovers. Not that I actually understand what happens to time values during DST Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 i want to show all the dates from start to end and echo those daes out please cheers. an example would be garate cheers. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 redarrow, I know you know how to write a for loop, as I've seen you write code more advanced than this for other people. Why don't you try something, and then we can help you edit it. btherl suggested a way to do it that will work with your existing code, so just plug it in. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 got no idear dosent work i am stuck no joke? Need help. <?php //get todays date $date_start=date("d-m-y"); //get todays date in a timestamp $date_start=strtotime($date_start); //make a timestamp and date to stop by $date_end= mktime(0, 0, 0, date("d")+7 , date("m"), date("Y")); //some for loop to get the start date to end date showing all dates for($i=$start_date; $i<$end_date; $i++){ $result='".[$i]$date_result."'; } //format the date result from the loop $date_result=date("y-m-d",$result); //echo the dates echo $date_result; ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 dont get it what was said here my current example please help cheers. <?php $date_start=date("d-m-y"); $date_end= mktime(0, 0, 0, date("d")+7 , date("m"), date("Y")); $date_result=date("y-m-d",$date_end); for($i=$date_start; $i<$date_result; $i++){ echo $date_start; } ?> Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 this is something like what you want i think: <?php //todays date is time() $date_start = time(); //get 7 days ahead. change 7 to any number of days $date_end = time() + 24 * 60 * 60 * 7; //some for loop to get the start date to end date showing all dates for($i = $date_start; $i < $date_end; $i += 84600){ $out_dates .= date("d-m-y", $i)."<br>"; } //echo out the dates echo $out_dates; ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 Thank you that what i wanted no one could help me thank you so mush now i need to learn it properly cheers. a++++++++++++ user Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 lol thanks. it took me 10 minutes to figure it out but yeh. i use timestamps a lot in my php work. glad to help 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.