mysql now()返回2018-00-00 0:00:00

时间:2018-09-21 17:43:42

标签: mysql sysdate

MySQL now()的月份,日期,小时,分钟和秒返回0值,但年份值正确。问题与sysdate()current_timestamp()相同。 current_date()current_time()返回正确的值。

mysql-sql> select now();
+--------------------+
| now()              |
+--------------------+
| 2018-00-00 0:00:00 |
+--------------------+
1 row in set (0.00 sec)
mysql-sql> select sysdate();
+--------------------+
| sysdate()          |
+--------------------+
| 2018-00-00 0:00:00 |
+--------------------+
1 row in set (0.00 sec)
mysql-sql> select current_timestamp;
+--------------------+
| current_timestamp  |
+--------------------+
| 2018-00-00 0:00:00 |
+--------------------+
1 row in set (0.00 sec)
mysql-sql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2018-09-21     |
+----------------+
1 row in set (0.04 sec)
mysql-sql> select current_time();
+----------------+
| current_time() |
+----------------+
| 22:08:47       |
+----------------+
1 row in set (0.00 sec)

我在Windows 10.0.17134.167中使用MySQL 5.7。系统时区为IST(+5.30)

mysql-sql> SELECT NOW(), @@global.time_zone AS gtz, @@session.time_zone AS stz;
+--------------------+--------+--------+
| NOW()              | gtz    | stz    |
+--------------------+--------+--------+
| 2018-00-00 0:00:00 | +05:30 | +05:30 |
+--------------------+--------+--------+
1 row in set (0.00 sec)

0 个答案:

没有答案