日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

php 日历重复_PHP 生成日历

發布時間:2025/4/16 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 日历重复_PHP 生成日历 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

效果如下:

PHP端代碼:

/**

* 日歷

*

* @param string month

*/

public static function day_report($params = [])

{

$month = $params['month'];

if (empty($month))

{

$month = date('Y-m');

}

$month_begin = strtotime($month . '-01');

$month_end = strtotime("+1 months", $month_begin) - 24*3600;

$dt_begin = $month_begin - (date('N', $month_begin)-1) * 24*3600;

$dt_end = $month_end + (7 - date('N', $month_end)) * 24*3600;

$today = strtotime(date('Y-m-d'));

$list = [];

$dt = $dt_begin;

while ($dt <= $dt_end)

{

$class = '';

if ($dt < $month_begin || $dt > $month_end)

{

$class .= ' other';

}

if ($dt == $today)

{

$class .= ' today';

}

if ($dt > $today)

{

$class .= ' future';

}

$list[] = [

'dt' => date('Y-m-d', $dt),

'day' => date('j', $dt),

'class' => $class,

];

$dt += 24*3600;

}

$list = array_chunk($list, 7);

// 月份選擇

$month_val = strtotime($month . '-01');

$month_cur = date('Y年m月', $month_val);

$month_pre = date('Y-m', strtotime("-1 months", $month_val));

$month_next = '';

if ($month != date('Y-m'))

{

$month_next = date('Y-m', strtotime("+1 months", $month_val));

}

$data = [

'month' => $month,

'list' => $list,

'month_cur' => $month_cur,

'month_pre' => $month_pre,

'month_next' => $month_next,

];

return self::_success($data);

}

HTML端代碼:

.h3-month

{

margin:10px 0;

}

.h3-month span

{

display:inline-block;

border-radius: 5px;

background-color: #eee;

border:solid 1px #ddd;

padding:0 10px;

font-size:0.9;

}

#tbDayList{

width:auto;

}

#tbDayList th{

font-size:30px;

}

#tbDayList .td-day{

width:100px;

height:10px;

line-height: 100px;

padding:0;

font-size:50px;

font-family:Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;

color:#72B9F7;

}

#tbDayList .other{

color:#999;

}

#tbDayList .future{

color:#bbb;

}

#tbDayList .today{

color:blue;

}

{ $month_cur }

{ if $month_next != '' }

{ /if }

周一周二周三周四周五周六周日

{ foreach $list as $week }

{ foreach $week as $r }

{ $r.day }

{ /foreach }

{ /foreach }

標簽:begin,日歷,list,month,strtotime,date,dt,PHP,生成

來源: https://www.cnblogs.com/zjfree/p/13197844.html

總結

以上是生活随笔為你收集整理的php 日历重复_PHP 生成日历的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。