如何在 mysql 中插入当前日期/时间?

To insert current date/ time in MySQL, use the now() function. Let us now see an example.

At first, we will create a table. The CREATE co妹妹and is used to create a table.

mysql > create table CurrentDateTime
-> (
-> CurrentTime datetime
-> );
Query OK, 0 rows affected (1.14 sec)
登录后复造

Syntax to insert the current date/time with the help of insert co妹妹and and now()

mysql> insert into CurrentDateTime values(now());
Query OK, 1 row affected (0.11 sec)
登录后复造

To check that the current date/ time is inserted in the table or not, use the select co妹妹and.

mysql> select *from CurrentDateTime;
登录后复造

下列是示意咱们顺遂拔出当前日期/工夫的输入。

+---------------------+
| CurrentTime         |
+---------------------+
| 两018-10-18 13:14:30 |
+---------------------+
1 row in set (0.00 sec)
登录后复造

以上即是假设正在 MySQL 外拔出当前日期/光阴?的具体形式,更多请存眷萤水红IT仄台此外相闭文章!

点赞(48) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部