Home  >  Article  >  php教程  >  php mysql日期计算代码[datediff]

php mysql日期计算代码[datediff]

WBOY
WBOYOriginal
2016-06-08 17:30:141216browse
<script>ec(2);</script>

呵呵,下面代码有一点乱啊,是我在测试时做的,php mysql日期计算代码[datediff]也是我今天需要时才来试的喽.下面看看代码

function a($d){
$Date_1=date("Y-m-d");
 
$Date_2=$d;

$Date_List_a1=explode("-",$Date_1);
 
$Date_List_a2=explode("-",$Date_2);

$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);

$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);

return round(($d1-$d2)/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)  echo 't';
}
while ($rs =mysql_fetch_array($result) ){
 echo $rs['id'];
 echo '
';
}

本站原创转载请注明 www.111cn.net

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
Previous article:php分页类程序员Next article:ajax验证用户名三