获得当前日期时间的mysql函数now()


  本文标签:mysql函数

  如果想要获得当前的日期和时间,应该如何实现呢?使用mysql函数now() ,就可以实现这项我们需要的功能,下面就为您详细介绍该mysql函数,供您参考  。

  mysql> select now();

  +---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
除了 now() 函数能获得当前的日期时间外,MySQL 中还有下面的mysql函数:

  current_timestamp()
,current_timestamp
,localtime()
,localtime
,localtimestamp -- (v4.0.6)
,localtimestamp() -- (v4.0.6)
这些日期时间mysql函数,都等同于 now()  。鉴于 now() 函数简短易记,建议总是使用 now() 来替代上面列出的mysql函数  。