php Calender(枱曆)代碼

來源:互聯網
上載者:User
php Calender(日曆)代碼
= 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 = <<
上一年 上一月 回到今天 下一月 下一年
{$year}年{$month}月
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 = ' '; $line .= str_repeat ( ' ', $nowWeek - 1 ); } if ($cday == $currentDay) { $style = 'style="color:red;"'; } else { $style = ''; } $line .= " "; //一周結束 if ($nowWeek == 7) { $line .= ' '; $html .= $line; $line = ' '; } //全月結束 if ($day == $lastday) { if ($nowWeek != 7) { $line .= str_repeat ( ' ', 7 - $nowWeek ); } $line .= ' '; $html .= $line; break; } $day ++; } $html .= <<
星期一 星期二 星期三 星期四 星期五 星期六 星期天
$day
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;}

  

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.