Home  >  Article  >  php教程  >  PHP计算时间段某天是星期几,当前时间后几天及日期时间差

PHP计算时间段某天是星期几,当前时间后几天及日期时间差

WBOY
WBOYOriginal
2016-06-13 10:04:121357browse

这几个时间函数都放出来了,使用方法不用说了吧!有什么不明白的地方可以在下面留言,我会及时回复地,交个朋友嘛~

 代码如下 复制代码


//取两个日期内天数差
function SubDay($ntime,$ctime)
{
$dayst = 3600 * 24;
$cday = ceil(($ntime-$ctime)/$dayst);
return $cday;
}
//取当前时间后几天,天数增加单位为1
function AddDay($ntime,$aday)
{
$dayst = 3600 * 24;
$oktime = $ntime + ($aday * $dayst);
return $oktime;
}
//取一周内的某天是星期几

function AddSpeDay($day=0)
{
//$day = isset($day) ? intval($day) : 0;
$daynum = date(‘w’) – $day;
$oktime = time() – (3600 * 24 * $daynum);
return $oktime;
}

#附php取当前时间的方法

//取当前时间,格式为2009-10-23 14:20:35

function GetDateTimeMk($mktime)
{
return MyDate(‘Y-m-d H:i:s’,$mktime);
}

//取当前时间,格式为2009-10-23

function GetDateMk($mktime)
{
return MyDate(“Y-m-d”,$mktime);
}

?>

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