note 126370 deleted from function.date by cmb

From: Date: Sat, 28 Aug 2021 22:06:34 +0000
Subject: note 126370 deleted from function.date by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216834@lists.php.net to get a copy of this message
Note Submitter: razvan_bc at yahoo dot com ---- life is fun .. you can build a entirely calendar in php for your time zone: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="Custa"> <title>PHP-BOOTSTRAP-CALENDAR</title> </head> <body> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js"></script> <?php date_default_timezone_set('Europe/Bucharest'); function w_d($d){ return 'LMMJVSD'[$d]; } function w_d2($d){ return ['Lun','Mar','Mie','Joi','Vin','Sâm','Dum'][$d]; } function cmax($mn,$yr){ //$mn=8;$yr=2021; return cal_days_in_month(CAL_GREGORIAN,$mn,$yr); } function s1tdayW($mn,$yr){ $res= date("w", strtotime($mn."/01/".$yr)); return ($res>0? $res-1 : 6); } function d($da,$mn,$yr){ $res= date("w", strtotime($mn."/".$da."/".$yr)); return ($res>0? $res-1 : 6); } function m($mo,$yr){ $head=''; for($i=0;$i<7;$i++){ $head.='<div class="col-1">'.w_d2($i).'</div>'; } $body=''; $k=0; $first=0-s1tdayW($mo,$yr)+1; for($i=$first;$i<=cmax($mo,$yr);$i++){ if($k==0) $body.= '<div class="row">'; $body.= '<div class="col-1 text-end border">'.($i>0? $i:'&nbsp;&nbsp;&nbsp;').'</div>'; if($k==6) $body.= '</div>'; $k++;if($k==7) $k=0; } echo<<<month <div class="pb-3"> <div class="container"> <div class="row w-100"> <div class="col-12"> {$mo}.{$yr} </div> </div> <div class="row text-end"> {$head} </div> {$body} </div> </div> month; } for($i=1;$i<13;$i++){ m($i,2021); } ?> </body> </html>

« previous php.notes (#216834) next »