calendrier

Par Mehdichakib, il y a 11 ans


Bonjour tous j'ai suivi votre tuto sur les calendriers et je voudrai afficher en plus de l'année courante l'année suivante j'ai réussi a récupérer les calendriers des deux années mais sans pour autant les afficher voici mon code

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="./s.css"> <title>Calendrier</title> <script type="text/javascript"> jQuery(function($){ $('.month').hide(); $('.month:first').show(); $('.months a:first').addClass('active'); var current = 1; $('.months a').click(function(){ var month = $(this).attr('id').replace('linkmonth',''); if(month != current){ $('#month'+current).slideUp(); $('#month'+month).slideDown(); $('.months a').removeClass('active'); $('.months a#linkmonth'+month).addClass('active'); current = month; } return false; }); }); </script> </head> <body> <?php require('date.php'); $date = new Date(); $year = date('Y'); $dates = $date->getAll($year); ?> <div class="periods"> <div class="year"> <ul> <?php foreach ($dates as $k=>$v ):?> <li> <a href="#" id="linkyear<?php echo $k;?>"> <?php echo $k; ?> </a> </li> <?php endforeach; ?> </ul> </div> <div class="clear"></div> <div class="months"> <ul> <?php foreach ($date -> months as $id=>$m):?> <li> <a href="#" id="linkmonth<?php echo $id+1;?>"> <?php echo utf8_encode(substr(utf8_decode($m), 0,3)); ?> </a> </li> <?php endforeach; ?> </ul> </div> <?php $dates = current($dates); ?> <?php foreach ($dates as $m => $days):?> <div class="clear"></div> <div class="month" id="month<?php echo $m; ?>"> <table> <thead> <tr> <?php foreach ($date->days as $d): ?> <th> <?php echo substr($d,0,3);?> </th> <?php endforeach;?> </tr> </thead> <tbody> <tr> <?php $end = end($days);foreach ($days as $d => $w):?> <?php if ($d == 1) :?> <?php if ($w != 1 ):?> <td colspan="<?php echo $w-1;?>" class="padding"></td> <?php endif;?> <?php endif;?> <td> <div class="relative"> <div class="day"> <?php echo $d;?></div> </div> </td> <?php if ($w == 7):?> </tr><tr> <?php endif;?> <?php endforeach;?> <?php if ($end != 7):?> <td colspan="<?php echo 7-$end;?>"class="padding"></td> <?php endif;?> </tr> </tbody> </table> </div> <?php endforeach;?> </div> </body> </html>

et aussi

<?php class Date{ var $days = array('Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche'); var $months = array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'); function getAll($year){ $r = array(); $limit = new DateTime($year.'-01-01'); $limit->add(new DateInterval('P1Y')); $date = new DateTime($year.'-01-01'); while ($date->format('Y') <= $limit->format('Y')) { # code... $y = $date->format('Y'); $m = $date->format('n'); $d = $date->format('j'); $w = str_replace('0', '7', $date->format('w')) ; $r[$y][$m][$d] = $w; $date->add(new DateInterval('P1D')); } return $r; } } ?>

2 réponses

daemon24, il y a 11 ans

C'est plutot celui ci

<?php echo strftime('%d/%m/%Y',strtotime('now + 1 year')); ?>
Mehdichakib, il y a 11 ans

$r contient deux calendriers 2014 et 2015 par exemple mais dans le premier bout de code (l'affichage) je veux faire une sorte de onclick ( quand je click sur 2014 il m'affiche calendrier 2014 et pareille pour 2015 .... )