Mysql database reads the statements from the front, back, back, to the back
Current Time:
select current_timestamp;
Output: 16:12:52
select now();
Output: 16:12:52
Take the first minute of the current time:
select SUBDATE(now(),interval 60 second);
Output: 16:11:52
Take the next minute of the current time:
select ADDDATE(now(),interval 60 second);
Output: 16:13:52
Change the unit above. Minutes, hours, and days can be used.
Take the time of the previous minute:
select SUBDATE(now(),interval 1 minute);
Output: 16:16:38
Take the time of the previous hour:
select SUBDATE(now(),interval 1 hour);
Output: 15:17:38
Take the time of the previous day:
select SUBDATE(now(),interval 1 day);
Output: 16:17:38
###########################
The last minute:
select ADDDATE(now(),interval 1 minute);
Output: 16:17:38
The next hour:
select ADDDATE(now(),interval 1 hour);
Output: 17:17:38
Time of the next day:
select ADDDATE(now(),interval 1 day);
Output: 16:17:38
The following is a supplement:
Mysql obtains the date of yesterday, today, tomorrow, and the time of the previous hour and the next hour.
1. Current date
select DATE_SUB(curdate(),INTERVAL 0 DAY) ;
2. Tomorrow's date
select DATE_SUB(curdate(),INTERVAL -1 DAY) ;
3. Date of yesterday
select DATE_SUB(curdate(),INTERVAL 1 DAY) ;
4. Last hour
select date_sub(now(), interval 1 hour);
5. the next hour
select date_sub(now(), interval -1 hour);
6. last 30 minutes
select date_add(now(),interval -30 minute)
7. 30 minutes later
select date_add(now(),interval 30 minute)
If you still don't want anything, read the following articles and thank you for your support.