mysql 插入ios8601
可以使用MySQL内置的函数NOW()来插入当前时间的ISO8601格式。具体操作如下:
- 创建一个表格:
CREATE TABLE `test_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
- 插入数据:
INSERT INTO `test_table` (`time`) VALUES (NOW());
- 查看插入的数据:
SELECT * FROM `test_table`;
输出结果类似于:
+----+---------------------+
| id | time |
+----+---------------------+
| 1 | 2021-10-27 09:30:45 |
+----+---------------------+
可以看到,插入的时间采用了ISO8601格式。
原文地址: https://www.cveoy.top/t/topic/BDb 著作权归作者所有。请勿转载和采集!