PHP calculation time period is the day of the week, the current time after a few days and a date difference _php tutorial

Source: Internet
Author: User
These time functions are put out, the use of the method needless to say! What do not understand the place can be in the following message, I will promptly reply to, make a friend ~
The code is as follows Copy Code


Take two days of the day difference
function Subday ($ntime, $ctime)
{
$dayst = 3600 * 24;
$cday = Ceil (($ntime-$ctime)/$dayst);
return $cday;
}
A few days after the current time, the number of days increases in units of 1
function Addday ($ntime, $aday)
{
$dayst = 3600 * 24;
$oktime = $ntime + ($aday * $dayst);
return $oktime;
}
Take a day of the week

function Addspeday ($day =0)
{
$day = Isset ($day)? Intval ($day): 0;
$daynum = Date (' W ') – $day;
$oktime = Time () – (3600 * $daynum);
return $oktime;
}

#附php取当前时间的方法

Take the current time, in the format 2009-10-23 14:20:35

function Getdatetimemk ($mktime)
{
Return mydate (' y-m-d h:i:s ', $mktime);
}

Take the current time, in the format 2009-10-23

function Getdatemk ($mktime)
{
Return MyDate ("y-m-d", $mktime);
}

?>

http://www.bkjia.com/PHPjc/631277.html www.bkjia.com true http://www.bkjia.com/PHPjc/631277.html techarticle These time functions are put out, the use of the method needless to say! What do not understand the place can be in the following message, I will promptly reply to, make a friend ~ code as follows copy Generation ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.