php+mysql 日期的写入读出操作
$conn_string = array ('server'=>'127.0.0.1','user'=>'root','password'=>'1230'); $conn = mysql_connect($conn_string['server'],$conn_string['user'],$conn_string['password']); mysql_select_db('test'); try { $now = date("Y-m-d 14:20:00"); $select_sql = "select name,insert_time from test where insert_time>'".$now."'"; $select_stmt = mysql_query($select_sql); while($row = mysql_fetch_assoc($select_stmt)) { print_r($row); } $count_sql = "select count(id) from test where insert_time>'".$now."'"; $count_stmt = mysql_query($count_sql); $count_num = mysql_fetch_row($count_stmt); print_r($count_num); }
$now = date("Y-m-d H:i:s"); $sql = "INSERT INTO test (`name` ,`insert_time` ) VALUES ('".$i."', '".$now."')"; $stmt = mysql_query ($sql);
关于mysql中日期datetime的操作测试。