当前位置:编程学习 > php >>

php mysql日期计算代码[datediff]

呵呵,下面代码有一点乱啊,是我在测试时做的,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)<5){
 echo 't';
}
while ($rs =mysql_fetch_array($result) ){
 echo $rs['id'];
 echo '<br>';
}

本站原创转载请注明 www.226511.com

补充:Php教程,Php常用代码 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,