
15/12/2011, 06:10
|
| | Fecha de Ingreso: mayo-2009
Mensajes: 382
Antigüedad: 15 años, 10 meses Puntos: 6 | |
Respuesta: obtener fechas entre dos fechas dadas He probado con todo, declara la fecha dentro de la funcion y fuera etc,
lo de funciones no lo conozco:
<?php
/**
* Returns an array with the dates between to dates given.
*
* @link http://us3.php.net/manual/en/function.date.php#AEN25217
*
* @param mixed $startdate Timestamp or strtotime() recognizeable string
* @param mixed $enddate Timestamp or strtotime() recognizeable string
* @param string[optional] $format date() format string
* @return mixed Array of timestamps or dates if given format
*/
function dates_between($startdate, $enddate, $format=null){
$startdate = 2012-01-01;
$enddate = 2012-12-31;
(is_int($startdate)) ? 1 : $startdate = strtotime($startdate);
(is_int($enddate)) ? 1 : $enddate = strtotime($enddate);
if($startdate > $enddate){
return false; //The end date is before start date
}
while($startdate < $enddate){
$arr[] = ($format) ? date($format, $startdate) : $startdate;
$startdate += 86400;
}
$arr[] = ($format) ? date($format, $enddate) : $enddate;
return $arr;
echo "$arr";
}
echo "$arr";
?> |