MySQL中提供了很多函数,为我们的SQL操作提供便利,例如:

    1. mysql> select NOW(), DATE_FORMAT( NOW(),'%Y-%m-%d %H:%i:%s') as time;
    2. +---------------------+---------------------+
    3. | NOW() | time |
    4. +---------------------+---------------------+
    5. | 2021-10-14 14:28:09 | 2021-10-14 14:28:09 |
    6. +---------------------+---------------------+
    1. mysql> select NOW(), DATE_FORMAT( NOW(),'%Y-%m-%d') as time;
    2. +---------------------+------------+
    3. | NOW() | time |
    4. +---------------------+------------+
    5. | 2021-10-14 14:28:58 | 2021-10-14 |
    6. +---------------------+------------+

    更多函数:https://dev.mysql.com/doc/refman/5.7/en/functions.html