mysql的datetime类型字段不能设置初值

解决方案 »

  1.   

    shijian datetime default 'now()'是这样吗?
      

  2.   

    $sql="create table xinxi(
          id int not null auto_increment,
      title varchar(250) not null,
      content text not null,
      shijian timestamp NOT NULL default '0000-00-00 00:00:00',
                primary key(id))";
      

  3.   

    $sql="create table xinxi(
          id int not null auto_increment,
      title varchar(250) not null,
      content text not null,
      shijian datetime NOT NULL default '0000-00-00 00:00:00',
                primary key(id))";$sql="create table xinxi(
          id int not null auto_increment,
      title varchar(250) not null,
      content text not null,
      shijian datetime NOT NULL default '".date(Y-m-j)."',
                primary key(id))";
      

  4.   

    string date ( string format [, int timestamp])
    返回将整数 timestamp 按照给定的格式字串而产生的字符串。如果没有给出时间戳则使用本地当前时间。换句话说,timestamp 是可选的,默认值为 time()。 
      

  5.   

    只有shijian datetime NOT NULL default '0000-00-00 00:00:00',这个可以出来。但放入数据库再输出出来是20060427193826 1 这样的。我不想要这样的效果。
    别的方法还是一样的结果0000_00_00 00:00:00。
    各位高手还有什么好办法吗?谢了!