MySQLnow()
为月、日、小时、分钟和秒返回 0 值,但年值是正确的。问题与sysdate()
,相同current_timestamp()
。Whilecurrent_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)