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

2015-01-24信息快讯网

利用php如何取得取得瑞年与平年中每月份的天数,如下函数

// 取得某月天数,可用于任意月份 
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; 
} 

©2014-2024 dbsqp.com