1。我有一组数据需要插入数据库,他们都带时间日期,他们的格式为:日/月/年/时间。具体有以下几种可能(有的后面带AM,PM):
26 October 2010, 08:16
29 October 2010, 13:45
31 October 2010, 1:02 pm
30 October 2010, 11:54 am
如何使插进数据库的日期,在PHP MYSQL QUERY时,可以按时间排序?
如果可能,是否可以统一时间?将AM,PM全都转换成24小时制?2。我不想将重复的数据插入进数据库,我用了以下代码却报错,如何修正?
mysql_query("INSERT INTO table (name,title,date) VALUES ('".$name."','".$title."','".$date."')" where title not in (select title from table) or name not in (select name from table));谢谢。

解决方案 »

  1.   

    1.使用timestamp类型。
    2.用and试试?
      

  2.   

    你以时间戳的形式插入数据库然后用读取数据的时候用PHP date()函数转换一下不可以吗?
      

  3.   

    怎样把时间转换成timestamp类型呢?
    具体时间并不是插入数据库时的时间。mysql_query("INSERT INTO table (name,title,date) VALUES ('".$name."','".$title."','".$date."')" where title not in (select title from table) and name not in (select name from table));换成and了,这下通过了,但是数据插不进去了(我把表清空后重新测试了)