欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php 取得瑞年与平年的天数的代码

程序员文章站 2023-11-30 20:34:58
复制代码 代码如下:// 取得某月天数,可用于任意月份 function getdays($month, $year) { switch($month) { case 4:...
复制代码 代码如下:

// 取得某月天数,可用于任意月份
function getdays($month, $year)
{
switch($month)
{
case 4:
case 6:
case 9:
case 11:
$days = 30;
break;
case 2:
if ($year%4==0)
{
if ($year 0==0)
{
$days = $year@0==0 ? 29 : 28;
}
else
{
$days =29;
}
}
else
{
$days = 28;
}
break;
default:
$days = 31;
break;
}
return $days;
}
**
* 根据时间戳取得对应的星期几
*
* @param int $time_stamp 时间戳
*/
function getweek($time_stamp)
{
$week_num = date("w",$time_stamp);
switch($week_num)
{
case "0":
$week = "日";
break;
case '1':
$week = "一";
break;
case '2':
$week = "二";
break;
case '3':
$week = "三";
break;
case '4':
$week = "四";
break;
case '5':
$week = "五";
break;
case '6':
$week = "六";
break;
}
return $week;
}