Table des matières
php Calender(日历)代码,phpcalender
php Calender(日历)代码,phpcalender
<?php /** * * 我的日历 * date_default_timezone_set date mktime * @param int $year * @param int $month * @param string $timezone * @author fc_lamp * @blog: http://www.cnblogs.com/roucheng/ */ function myCalender($year = '', $month = '', $timezone = 'Asia/Shanghai') { date_default_timezone_set ( $timezone ); $year = abs ( intval ( $year ) ); $month = abs ( intval ( $month ) ); //是否是32位机 if (is32()) { if ($year < 1970 or $year >= 2038) { $year = date ( 'Y' ); } } else { if ($year <= 0) { $year = date ( 'Y' ); } } if ($month <= 0 or $month > 12) { $month = date ( 'm' ); } //上一年 $pretYear = $year - 1; //上一月 $mpYear = $year; $preMonth = $month - 1; if ($preMonth <= 0) { $preMonth = 1; $mpYear = $pretYear; } //下一年 $nextYear = $year + 1; //下一月 $mnYear = $year; $nextMonth = $month + 1; if ($nextMonth > 12) { $nextMonth = 1; $mnYear = $nextYear; } //日历头 $html = <<<HTML <table width="500" border="1"> <tr align="center"> <td><a href="?y=$pretYear">上一年</a></td> <td><a href="?y=$mpYear&m=$preMonth">上一月</a></td> <td><a href="?">回到今天</a></td> <td><a href="?y=$mnYear&m=$nextMonth">下一月</a></td> <td><a href="?y=$nextYear">下一年</a></td> </tr> <tr align="center"> <td colspan="5">{$year}年{$month}月</td> </tr> <tr> <td colspan="5"> <table width="100%" border="1"> <tr align="center"> <td style="background-color:#DAF0DD;">星期一</td> <td style="background-color:#DAF0DD;">星期二</td> <td style="background-color:#DAF0DD;">星期三</td> <td style="background-color:#DAF0DD;">星期四</td> <td style="background-color:#DAF0DD;">星期五</td> <td style="background-color:#F60;color:#fff;font-weight: bold;">星期六</td> <td style="background-color:#F60;color:#fff;font-weight: bold;">星期天</td> </tr> HTML; $currentDay = date ( 'Y-m-j' ); //当月最后一天 $lastday = date ( 'j', mktime ( 0, 0, 0, $nextMonth, 0, $year ) ); //循环输出天数 $day = 1; $line = ''; while ( $day <= $lastday ) { $cday = $year . '-' . $month . '-' . $day; //当前星期几 $nowWeek = date ( 'N', mktime ( 0, 0, 0, $month, $day, $year ) ); if ($day == 1) { $line = '<tr align="center">'; $line .= str_repeat ( '<td> </td>', $nowWeek - 1 ); } if ($cday == $currentDay) { $style = 'style="color:red;"'; } else { $style = ''; } $line .= "<td $style>$day</td>"; //一周结束 if ($nowWeek == 7) { $line .= '</tr>'; $html .= $line; $line = '<tr align="center">'; } //全月结束 if ($day == $lastday) { if ($nowWeek != 7) { $line .= str_repeat ( '<td> </td>', 7 - $nowWeek ); } $line .= '</tr>'; $html .= $line; break; } $day ++; } $html .= <<<HTML </table> </td> </tr> </table> HTML; return $html; } /** * * 检测是否是32位机 * @author fc_lamp * @blog: fc-lamp.blog.163.com */ function is32() { $is32 = False; if (strtotime ( '2039-10-10' ) === False) { $is32 = True; } return $is32; }
Copier après la connexion
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud
R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
3 Il y a quelques semaines
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Meilleurs paramètres graphiques
3 Il y a quelques semaines
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Solution d'énigmes de coquille
2 Il y a quelques semaines
By DDD
R.E.P.O. Comment réparer l'audio si vous n'entendez personne
3 Il y a quelques semaines
By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Comment déverrouiller tout dans Myrise
3 Il y a quelques semaines
By 尊渡假赌尊渡假赌尊渡假赌

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)