PHP calculates the day of the week for a certain day in a time period, the number of days after the current time and the date and time difference_PHP Tutorial

WBOY
Release: 2016-07-13 17:00:08
Original
1358 people have browsed it

These time functions have been released. Needless to say how to use them! If there is anything you don’t understand, you can leave a message below and I will reply in time. Make a friend~

The code is as follows
 代码如下 复制代码


//取两个日期内天数差
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);
}

?>

Copy code

//Get the difference in days between two dates
function SubDay($ntime,$ctime)
{
$dayst = 3600 * 24;
$cday = ceil(($ntime-$ctime)/$dayst);
return $cday;
}
//Get the number of days after the current time, and the increment unit of the number of days is 1
function AddDay($ntime,$aday)
{
$dayst = 3600 * 24;
$oktime = $ntime + ($aday * $dayst);
return $oktime;
}
//Get the day of the week that a certain day of the week is

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

//Get the current time, the format is 2009-10-23 14:20:35 function GetDateTimeMk($mktime)
{
return MyDate(‘Y-m-d H:i:s’,$mktime);
}
//Get the current time, the format is 2009-10-23 function GetDateMk($mktime)
{
return MyDate(“Y-m-d”,$mktime);
}
?>
http://www.bkjia.com/PHPjc/631277.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631277.htmlTechArticleThese time functions have been released. Needless to say how to use them! If there is anything you don’t understand, you can leave a message below and I will reply in time. Make a friend~ The code is as follows. Copy code...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!