用now()取得的时间格式为:0000-00-00 00:00:00
用time()取得的是当前时间戳.

解决方案 »

  1.   

    表单的页:  
    <form name="form1" method="post" action="b.php">    <input type="text" name="aa1">    <input type="text" name="aa2"></form>处理表单的页: b.php
    $nowtime = time();  //获得当前的时间.
    $aa1 = $_POST['aa1'];  //接收数据
    $aa2 = $_POST['aa2'];
    $db = mysql_connect("主机名","用户名","密码");  //链接mysql
    mysql_select_db("数据库名",$db);                //选择数据库
    $sql = "INSERT into table_name (`string1`,`string2`,`date`) values('$aa1','$aa2','$nowtime')";
    mysql_query($sql,$db);                         //执行sql语句
      

  2.   

    $Tdate=date("Y-m-d"); //取得当前时间,时间格式为'年-月-日'insert的时候只要这样写就可以了
    insert into table values('".$Tdate."');