在mysql中可以调用哪个时间函数获得当前的时间格式为:yyyy-MM-dd hh:mm:ss格式的,我查了好些都不尽人意,请大家帮忙提示一下

解决方案 »

  1.   

    mysql> select date_format(now(),'%Y-%m-%d %H:%i:%s');
    +----------------------------------------+
    | date_format(now(),'%Y-%m-%d %H:%i:%s') |
    +----------------------------------------+
    | 2009-12-28 21:21:42                    |
    +----------------------------------------+
    1 row in set (0.00 sec)mysql>
      

  2.   

    嗯,是的啊,不过我的mysql中使用select now();却获取不到这种格式的效果,请问是什么原因啊?
      

  3.   

    你用一楼的方法显示得是什么?另外检查一下你的系统变量mysql> show variables like '%time_format%';
    +-----------------+-------------------+
    | Variable_name   | Value             |
    +-----------------+-------------------+
    | datetime_format | %Y-%m-%d %H:%i:%s |
    | time_format     | %H:%i:%s          |
    +-----------------+-------------------+
    2 rows in set (0.00 sec)mysql>
      

  4.   

    select date_format(now(),'%Y-%m-%d %H:%i:%s');