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
| <?php
$joursarray = array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
$moisarray = array(1 => "Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
$t = 60*60*24*30; //+1 mois
$timestamp= time();
$time= $timestamp + $t; // addition date du jour + 1 mois
$date= date('d/m/Y', $time); //calcul de la future date grace au timestamp
$datebis = explode("/", $date);
$day= $datebis[0];
$mois= $datebis[1];
$an= $datebis[2];
$time = mktime(0, 0, 0, $day, $mois, $an);
$jour_semaine = date("w", $time);
$jourchoisi='lundi';
// L'internaute choisit comme point de depart un lundi (le jour sera obtenu par formulaire)
if ($jourchoisi == 'lundi') {
if ($jour_semaine == 1) {
$next_monday = $day+7; }
else {
$next_monday = $day+8-$jour_semaine;
$next_time = mktime(0, 0, 0, $mois, $next_monday, $an);
echo "<p>Le lundi suivant est le ".$joursarray[date("w", $next_time)]." ".date("j", $next_time)." ".$moisarray[date("n", $next_time)]." ".date("Y", $next_time)."</p>\r\n";
}
}
//Sinon c'est un dimanche
else
{
if ($jour_semaine == 0) {
$next_dim = $day+7; }
else {
$next_dim = $day+7-$jour_semaine;
$next_time = mktime(0, 0, 0, $mois, $next_dim, $an);
echo "<p>Le dimanche suivant est le ".$joursarray[date("w", $next_time)]." ".date("j", $next_time)." ".$moisarray[date("n", $next_time)]." ".date("Y", $next_time)."</p>\r\n";
}
}
?> |