Mysql method to get the current time: You can get the current time by executing the [select now();] statement. It can also be obtained by executing the [select current_timestamp, current_timestamp();] statement.
Get the current date and time (date time) function: now()
(Recommended tutorial: mysql video tutorial )
mysql> select now(); +---------------------+ | now() | +---------------------+ | 2008-08-08 22:20:46 | +---------------------+
Get the current date and time (date time) function: sysdate()
sysdate() The date and time function is similar to now(), except that now() starts at the beginning of execution The time value is obtained, and sysdate() obtains the value dynamically when the function is executed. Look at the following example to understand:
mysql> select now(), sleep(3), now(); +---------------------+----------+---------------------+ | now() | sleep(3) | now() | +---------------------+----------+---------------------+ | 2008-08-08 22:28:21 | 0 | 2008-08-08 22:28:21 | +---------------------+----------+---------------------+
MySQL Get the current timestamp function: current_timestamp, current_timestamp()
mysql> select current_timestamp, current_timestamp(); +---------------------+---------------------+ | current_timestamp | current_timestamp() | +---------------------+---------------------+ | 2008-08-09 23:22:24 | 2008-08-09 23:22:24 | +---------------------+---------------------+
Related recommendations: mysql tutorial
The above is the detailed content of How to get the current time in mysql. For more information, please follow other related articles on the PHP Chinese website!