English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To insert the current date into MySQL/To select time, please usenow()
functions. Now let's look at an example.
Firstly, we will create a table. The CREATE command is used to create tables.
mysql > create table CurrentDateTime -> ( -> CurrentTime datetime -> );
With the help of the insert command and the current date/Time insertion syntax now()
mysql> insert into CurrentDateTime values(now());
To check if the current date has been inserted into the table/To select time, please use the select command.
mysql> select *from CurrentDateTime;
Below is the display of the current date we have successfully inserted/Time output.
+---------------------+ | CurrentTime | +---------------------+ | 2018-10-18 13:14:30 | +---------------------+ 1 row in set (0.00 sec)