Query SELECT NOW() gives the current date and current time. Only use CURDATE() if you only need the current date. The following is the syntax for datetime -
SELECT NOW();
The syntax for date only.
SELECT CURDATE();
Let us now implement the above syntax −
Case 1: If you want the current date and time −
mysql> SELECT NOW();
+-----------------------+ | NOW() | +-----------------------+ | 2019-06-02 15 :30 :39 | +-----------------------+ 1 row in set (0.00 sec)
Case 2: If you only want the current date -
mysql> SELECT CURDATE();
+------------+ | CURDATE() | +------------+ | 2019-06-02 | +------------+ 1 row in set (0.00 sec)
The above is the detailed content of MySQL query to get current date time and only current date. For more information, please follow other related articles on the PHP Chinese website!