1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| <?php
$xml = simplexml_load_file('xXxXxXx.xml');
function ObtenirDates ($Debut, $Fin) {
$Start = strtotime ($Debut);
$End = strtotime ($Fin);
if (false === $Start || false === $End) {
return false;
}
$aStart = explode ('-', $Debut);
$aEnd = explode ('-', $Fin);
if (count ($aStart) !== 3 || count ($aEnd) !== 3) {
return false;
}
if (false === checkdate ($aStart[1], $aStart[2], $aStart[0]) || false === checkdate ($aEnd[1], $aEnd[2], $aEnd[0]) || $End <= $Start) {
return false;
}
for ($i = $Start+86400; $i <$End; $i += 86400 ) {
$Dates[] = strftime ('%d/%m/%Y', $i);
}
if (isset ($Dates) && !empty ($Dates) ) {
return $Dates;
} else {
return false;
}
}
foreach ($xml->task as $tache)
{
// variable $date du style : JJ/MM/AAAA
$date = explode("/",$tache->start);
// extraction des jour, mois, an de la date
list($d, $m, $y) = explode('/', $tache->start);
$timestamp = mktime ($d, $m, $y);
$array= array ( $y, $m, $d);
$deb = implode ('-', $array );
$fin = date ("Y-m-d");
$Dates = ObtenirDates ($deb, $fin);
echo '<pre>', print_r ($Dates), '</pre>';
}
?> |
Partager