- Messages : 3
- Remerciements reçus 0
Connexion ou Créer un compte pour participer à la conversation.
Connexion ou Créer un compte pour participer à la conversation.
$start = new DateTime($startdate);
if(is_array( $array['daysOfWeek'])){
$weekdays = $array['daysOfWeek'];
$array['daysOfWeek'] = implode(",",$weekdays);
}else{
$weekdays = explode(",",$array['daysOfWeek']);
}
$tempWeekDays = array(
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
);
if($weekdays == NULL) $weekdays= array(0,1,2,3,4,5,6);
foreach($weekdays as $weekday){
if (class_exists('DateInterval')) {
$temp = $start;
$temp->modify("+1 ".$tempWeekDays[$weekday]);
// Create array with all dates of the period - php 5.3
$date_interval = new DateInterval("P7D");
$end = new DateTime($enddate);
// Retourne toutes les dates.
$perioddates[] = new DatePeriod($temp, $date_interval, $end);
$out = array();
} else {
// Create array with all dates of the period - php 5.2
if (($startdate != $nodate) && ($enddate != $nodate)) {
$temp = $start;
$temp->modify("+1 ".$tempWeekDays[$weekday]); //$end = new DateTime(date("Y-m-d H:i",strtotime("+0 day", strtotime($enddate))));
$end = new DateTime($enddate);
while($start < $end) {
$out[] = $start->format('Y-m-d H:i');
$temp->modify('+7 day');
}
}
echo("PHP5.2");
}
}
// Prépare serialize.
if (!empty($perioddates) && is_array($perioddates)) {
foreach($perioddates as $pd)
foreach($pd as $dt) {
$out[] = (
$dt->format('Y-m-d H:i')
);
}
}
sort($out);
// Serialize les dates de la période.
if (($startdate != $nodate) && ($enddate != $nodate)) {
$array['period'] = serialize($out);
$ctrl=unserialize($array['period']);
if(is_array($ctrl)){
$period=unserialize($array['period']);
dump($period,"array");
}else{
$period=$this->getPeriod($array['period']);
dump($period,"noarray");
}
rsort($period);
$array['period']=serialize($period);
} else {
$array['period']='';
}
Connexion ou Créer un compte pour participer à la conversation.
Connexion ou Créer un compte pour participer à la conversation.