PHP mysql Date calculation code [DATEDIFF]

Source: Internet
Author: User
Tags explode php mysql

Oh, the following code is a little messy ah, is what I do in the test, PHP mysql date calculation code [DATEDIFF] is also I need today to try it. Look at the code here.

function A ($d) {
$Date _1=date ("y-m-d");

$Date _2= $d;

$Date _list_a1=explode ("-", $Date _1);

$Date _list_a2=explode ("-", $Date _2);

$d 1=mktime (0,0,0, $Date _list_a1[1], $Date _list_a1[2], $Date _list_a1[0]);

$d 2=mktime (0,0,0, $Date _list_a2[1], $Date _list_a2[2], $Date _list_a2[0]);

Return round ($d 1-$d 2)/3600/24);
}

Echo $Days;

$d =date ("y-m-d h:i:s");
$sql = "SELECT * from Wk_member where m_ip= ' 127.0.0.1 ' and DateDiff (m_dtime, ' $d ') =0";
$result =mysql_query ($sql) or Die (Mysql_error ());
if (mysql_num_rows ($result) <5) {
echo ' t ';
}
while ($rs =mysql_fetch_array ($result)) {
echo $rs [' id '];
Echo ' <br> ';
}

Original site reproduced please specify www.111cn.net

Related Article

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.