這篇文章將為大家詳細講解有關(guān)怎么在PHP項目中實現(xiàn)一個日歷功能,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。
創(chuàng)新互聯(lián)建站主營巨鹿網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶APP開發(fā),巨鹿h5微信小程序開發(fā)搭建,巨鹿網(wǎng)站營銷推廣歡迎巨鹿等地區(qū)企業(yè)咨詢具體如下:
<?php header("Content-Type:text/html;charset=utf-8"); date_default_timezone_set("PRC"); $a=@$_GET["a"]; $b=@$_GET["b"]; if($a){ $a=$a; }else{ $a=date('y'); } if($b){ $b=$b; }else{ $b=date('m'); } $noe=mktime(0,0,0,$b,1,$a); //獲取當前的月的一號 $year=date("Y",$noe); //當前的年 $month=date("m",$noe); //當前的月 $week=date("w",$noe); // 每個月的一號是星期幾 $days=date("t",$noe); //每個月的總天數(shù) $day=date("d"); //獲取今天是幾號 $as=$year-1; //獲取上一年的年 $bs=$month-1; //獲取上個月 $bs=$month+1; // 獲取下個月 $as=$year+1; //獲取下一年 ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>日歷</title> <style> table{ border: 1px solid #050; } table th{ background:#000; color:#fff; border: 2px solid #050; } </style> </head> <body> <table cellpadding="0" cellspacing="0"> <tr> <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" ><<上一年</a></th> <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" ><<上個月</a></th> <th><?php echo $year."-".$month."-".$day ?></th> <th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" >下個月>></a></th> <th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" >下一年>></a></th> </tr> <tr> <th>星期日</th> <th>星期一</th> <th>星期二</th> <th>星期三</th> <th>星期四</th> <th>星期五</th> <th>星期六</th> </tr> <tr> <?php for($i=0;$i<$week;$i++){ echo "<td> </td>"; //獲取當月一號前面的空格 } for($k=1;$k<=$days;$k++){ if($k==$day){ echo "<th>".$k."</th>"; //輸出今天是幾號 }else{ echo "<td>".$k."</td>"; //輸出當月天數(shù) } if(($k+$week)%7==0){ echo "<tr></tr>"; // 一周七天換行 } } ?> </tr> </table> </body> </html>
運行結(jié)果:
關(guān)于怎么在PHP項目中實現(xiàn)一個日歷功能就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
當前文章:怎么在PHP項目中實現(xiàn)一個日歷功能-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://muchs.cn/article40/cdddeo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、電子商務(wù)、定制開發(fā)、微信公眾號、關(guān)鍵詞優(yōu)化、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容