#获取当前时间:

SELECT NOW() AS newTime;    #2019-05-20 14:28:41

#当前时间减30秒:

SELECT (NOW() - INTERVAL 30 SECOND) AS newTime;    #2019-05-20 14:29:31

#当前时间加30秒:

SELECT (NOW() + INTERVAL 30 SECOND) AS newTime;    #2019-05-20 14:29:31

#当前时间减30分钟:

SELECT (NOW() - INTERVAL 30 MINUTE) AS newTime;    #2019-05-20 14:02:26

#当前时间加30分钟:

SELECT (NOW() + INTERVAL 30 MINUTE) AS newTime;    #2019-05-20 15:02:41

#当前时间减1天:

SELECT (NOW() - INTERVAL 1 DAY) AS newTime;        #2019-05-19 14:33:26

#当前时间加1天:

SELECT (NOW() + INTERVAL 1 DAY) AS newTime;        #2019-05-21 14:33:33

#当前时间减1个月:

SELECT (NOW() - INTERVAL 1 MONTH) AS newTime;        #2019-04-20 14:34:10

#当前时间加1个月:

SELECT (NOW() + INTERVAL 1 MONTH) AS newTime;        #2019-06-20 14:34:47

#当前时间减1年:

SELECT (NOW() - INTERVAL 1 YEAR) AS newTime;        #2018-05-20 14:35:09

#当前时间加1年:

SELECT (NOW() + INTERVAL 1 MONTH) AS newTime;        #2019-06-20 14:35:23

#指定时间的加减:

将上面的NOW()函数换为指定日期时间即可,以加30分钟为例,如下:

SELECT ('2019-01-02 12:30:00' + INTERVAL 30 MINUTE) AS newTime;        #2019-01-02 13:00:00

 

 

06-03 09:58