Get the current time: select current_timestamp; Output: 2016-06-16 16:12:52 select now(); Output: 2016-06-16 16:12:52 Get the minute before the current time: select SUBDATE(now(),interval 60 second); Output: 2016-06-16 16:11:52 Get the next minute from the current time: select ADDDATE(now(),interval 60 second); Output: 2016-06-16 16:13:52 By changing the units above. Can get the time before and after minutes, hours, days Get the time of the previous minute: select SUBDATE(now(),interval 1 minute); Output: 2016-06-16 16:16:38 Get the time of the previous hour: select SUBDATE(now(),interval 1 hour); Output: 2016-06-16 15:17:38 Get the time of the previous day: select SUBDATE(now(),interval 1 day); Output: 2016-06-15 16:17:38 Take the time after one minute: select ADDDATE(now(),interval 1 minute); Output: 2016-06-16 16:17:38 One hour after the pick-up: select ADDDATE(now(),interval 1 hour); Output: 2016-06-16 17:17:38 Time after the day of collection: select ADDDATE(now(),interval 1 day); Output: 2016-06-17 16:17:38 The following are supplements: mysql gets yesterday's date, today's date, tomorrow's date, 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. Yesterday's date 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. First 30 minutes select date_add(now(),interval -30 minute) 7. Last 30 minutes select date_add(now(),interval 30 minute) If you still can't find what you want, you can check out the related articles below. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Solve the problem of forgetting password in MySQL 5.7 under Linux
>>: React Hook usage examples (6 common hooks)
We all know that Docker containers are isolated f...
In the previous article, we used Docker to build ...
How to solve the problem of being unable to acces...
Table of contents Problem description: Solution 1...
This article example shares the specific code of ...
Building an image is a very important process in ...
1. Configuration By default, the first two are no...
I have been working on a project recently - Budou ...
This article shares the specific code of Vue to a...
MySQL downloads for all platforms are available a...
Dockerfile is a file used to build a docker image...
When I was interviewing for a BI position at a ce...
Introduction to IPSec IPSec (Internet Protocol Se...
I won't say much nonsense, let's just loo...
background Sometimes we need to get the creation ...