MySQL 获取当前日期及日期格式
获取系统日期: NOW()
格式化日期: DATE_FORMAT(date, format)
注: date:时间字段
format:日期格式
返回系统日期,输出 2009-12-25 14:38:59
格式化 当前日期
mysql>
select date_format(now(),'%y-%m-%d');+
-----------+
| 20-12-0 |
+
-----------+
MySQL 获得当前日期时间 函数
1 获得当前日期+时间(date + time)函数:now() 年月日时分秒都显示
mysql>
select
now();
+
---------------------+
| now() |
+
---------------------+
| 2020-12-02 14:55:44 |
+
---------------------+
2. 获得当前日期(date)函数:curdate() 只显示当前 年月日
mysql>
select
curdate();
+
------------+
| curdate() |
+
------------+
| 2020-12-02|
+
------------+
mysql>
select
curtime();
+
-----------+
| curtime() |
+
-----------+
| 14:55:58 |
+
-----------+
4. 获得当前 UTC 日期时间函数:utc_date(), utc_time(), utc_timestamp()
mysql>
select
utc_timestamp(), utc_date(), utc_time(), now()
+
---------------------+------------+------------+---------------------+
| utc_timestamp() | utc_date() | utc_time() | now() |
+
---------------------+------------+------------+---------------------+
| 2008-08-08 14:47:11 | 2008-08-08 | 14:47:11 | 2008-08-08 22:47:11 |
+
---------------------+------------+------------+---------------------+