Jump to content

Obtain days between dates


Julian

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.