@MySQL get the current date time (and the conversion of the time)
Localtimestamp () Localtimestamp
These date-time functions are equivalent to now (). Since the now () function is short and easy to remember, it is recommended that you always use now () instead of the functions listed above.
1.2 Get the current date + time (date + times) function: Sysdate ()
The Sysdate () date-time function is similar to now (), except that it is obtained at the execution start value, and sysdate () dynamically gets the value when the function executes.
Second, MySQL date time Extract (select) function.
Select Extract (microsecond from @dt); --123456
Select Extract (Day_minute from @dt); --100715
The MySQL Extract () function has no function other than date (), Time (), and all other functions one should. And also has the choice ' day_microsecond ' and so on function. Note that this is not just the day and the microsecond, but the part of the date that has been selected to the Microsecond section.
6. MySQL Last_day () function: Returns the last day of the month.
1. MySQL adds a time interval for the date: Date_add ()
+------------------------------------------------+
The Date_add () function adds "1 hours, 15 minutes, 30 seconds" and "1 days, 1 hours, 15 minutes, 30 seconds" for @dt respectively.
Recommendation: Always use the Date_add () date-time function instead of adddate (), Addtime (). <br><br>
The format of the function parameter "P" is "yyyymm" or "yymm", and the second parameter "n" means increment or subtract N month (month).
Select To_days (' 2008-08-08 '); --733627
Select Str_to_date (' 08:09:30 ', '%h:%i:%s '); -08:09:30
Select Get_format (date, ' internal '); --'%y%m%d '
Select Get_format (datetime, ' internal '); --'%y%m%d%h%i%s '
Select Get_format (Time, ' ISO '); --'%h:%i:%s '
V. MySQL timestamp (Timestamp) function
Time zone conversions can also be achieved by Date_add, Date_sub, Timestampadd.
Select Date_add (' 2008-08-08 12:00:00 ', Interval-8 hour); --2008-08-08 04:00:00
Select Timestampadd (Hour,-8, ' 2008-08-08 12:00:00 '); --2008-08-08 04:00:00
MySQL gets the current date time (and the time conversion)