php Calender(日历)代码分享_php实例
程序员文章站
2024-02-12 11:41:46
...
代码如下:
/**
*
* 我的日历
* date_default_timezone_set date mktime
* @param int $year
* @param int $month
* @param string $timezone
* @author fc_lamp
*/
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 = 2038)
{
$year = date ( 'Y' );
}
} else
{
if ($year {
$year = date ( 'Y' );
}
}
if ($month 12)
{
$month = date ( 'm' );
}
//上一年
$pretYear = $year - 1;
//上一月
$mpYear = $year;
$preMonth = $month - 1;
if ($preMonth {
$preMonth = 1;
$mpYear = $pretYear;
}
//下一年
$nextYear = $year + 1;
//下一月
$mnYear = $year;
$nextMonth = $month + 1;
if ($nextMonth > 12)
{
$nextMonth = 1;
$mnYear = $nextYear;
}
//日历头
$html =
HTML;
return $html;
}
复制代码 代码如下:
/**
*
* 我的日历
* date_default_timezone_set date mktime
* @param int $year
* @param int $month
* @param string $timezone
* @author fc_lamp
*/
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 = 2038)
{
$year = date ( 'Y' );
}
} else
{
if ($year {
$year = date ( 'Y' );
}
}
if ($month 12)
{
$month = date ( 'm' );
}
//上一年
$pretYear = $year - 1;
//上一月
$mpYear = $year;
$preMonth = $month - 1;
if ($preMonth {
$preMonth = 1;
$mpYear = $pretYear;
}
//下一年
$nextYear = $year + 1;
//下一月
$mnYear = $year;
$nextMonth = $month + 1;
if ($nextMonth > 12)
{
$nextMonth = 1;
$mnYear = $nextYear;
}
//日历头
$html =
上一年 | 上一月 | 回到今天 | 下一月 | 下一年 | ||||||||||
{$year}年{$month}月 | ||||||||||||||
|
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;
}
上一篇: mysql 语句关联查询问题
下一篇: PHP正则替换preg_replace