Home  >  Article  >  Backend Development  >  PHP code to get the number of days between Rui Nian and Ping Nian_PHP Tutorial

PHP code to get the number of days between Rui Nian and Ping Nian_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:45:111196browse

Copy code The code is as follows:

// Get the number of days in a certain month, which can be used in any month
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;
}
**
* Get the corresponding day of the week based on the timestamp
*
* @param int $time_stamp timestamp
*/
function getWeek($time_stamp)
{
$week_num = date("w",$time_stamp);
switch($week_num)
{
case "0":
$week = "day";
break;
case '1':
$week = "一";
break;
case '2':
$week = "二";
break;
case ' 3':
$week = "三";
break;
case '4':
$week = "四";
break;
case '5':
$week = "five";
break;
case '6':
$week = "six";
break;
}
Return $week;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320400.htmlTechArticleCopy code The code is as follows: // Get the number of days in a certain month, which can be used in any month function getDays($month, $year ) { switch($month) { case 4: case 6: case 9: case 11: $days = 30; break; case 2...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn