Julian Posted April 11, 2008 Share Posted April 11, 2008 Hi guys I making an events calendar for my website. I have the calendar script that suit my needs. Thanks to Keith Devens at http://keithdevens.com/software/php_calendar I stored the information of each event on the database `news` also included startdate and enddate as date only. What I'm trying to do is get those days in between `startdate and enddate` in order to show as links in the calendar for each event. The script that shows the calendar as follows.. <?php $time = time(); $today = date('j',$time); $oldlocale = setlocale(LC_TIME, NULL); #save current locale setlocale(LC_TIME, 'es_ES'); #Spanish //New month if ($mes <= '12'){ $new_mes = ($mes + 1); } $new_year = ($ano + 1); $new_month = ($new_mes - 12); $old_year = ($ano - 1); $old_month = ($mes + 11); $old_mes = ($mes - 1); if ($new_mes > 12){ $pn = array('«'=>'users2.php?mes='.$old_month.'&ano='.$old_year, '»'=>'users2.php?mes='.$new_month.'&ano='.$new_year); } else { $pn = array('«'=>'users2.php?mes='.$old_mes.'&ano='.$ano, '»'=>'users2.php?mes='.$new_mes.'&ano='.$ano); } //Here is where I need to get those days in betwen $days = array();$c = 0; while ($row_calendar = mysql_fetch_assoc($calendar)) { $c++; $d = $row_calendar['days_in_betwen']; //This is where I got lost. $l = 'users2.php?dia='.$d.'&mes='.$mes.'&ano='.$ano; $days[$d][] = $l; } echo generate_calendar($ano, $mes , $days, 1, NULL, 0, $pn); setlocale(LC_TIME, $oldlocale); ?> Thanks guys for the help. Best regards Link to comment https://forums.phpfreaks.com/topic/100651-obtain-days-between-dates/ Share on other sites More sharing options...
Julian Posted April 11, 2008 Author Share Posted April 11, 2008 Hi Guys!! Any hint? Regards Link to comment https://forums.phpfreaks.com/topic/100651-obtain-days-between-dates/#findComment-515146 Share on other sites More sharing options...
discomatt Posted April 11, 2008 Share Posted April 11, 2008 SELECT `cols` FROM `table` WHERE `date` BETWEEN '1900-01-01 00:00:00' AND '2008-04-11 14:45:00' Link to comment https://forums.phpfreaks.com/topic/100651-obtain-days-between-dates/#findComment-515207 Share on other sites More sharing options...
Julian Posted April 11, 2008 Author Share Posted April 11, 2008 Hi, thanks for the reply. I think is not that simple as that. If you read my post I need to get everyday number between startdate and enddate, then create a loop with those days in order to add each day as links to my calendar. Regards Link to comment https://forums.phpfreaks.com/topic/100651-obtain-days-between-dates/#findComment-515248 Share on other sites More sharing options...
kenrbnsn Posted April 11, 2008 Share Posted April 11, 2008 If you want the dates between two dates you can do something like this: <?php $sd = '2008-4-1'; $ed = '2008-5-15'; for ($i=strtotime($sd);$i<strtotime($ed);$i+=86400) echo date('Y-m-d',$i)."<br>\n"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/100651-obtain-days-between-dates/#findComment-515261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.