php mysql日期计算代码[datediff]
呵呵,下面代码有一点乱啊,是我在测试时做的,php mysql日期计算代码[datediff]也是我今天需要时才来试的喽.下面看看代码
<?php 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>'; }
永久地址:http://www.phprm.com/code/d40b994ac43e630f316940ea4976564c.html
转载随意~请带上教程地址吧^^