发布网友 发布时间:2022-04-23 13:06
共3个回答
懂视网 时间:2022-04-29 21:01
现在,新建一张数据库表t_stu_info,并向表里插入数据
use test; show tables; create table t_stu_info( id int not null primary key, stu_name varchar(20), stu_date timestamp, stu_age int(3), stu_sex varchar(5) ); insert into t_stu_info(id,stu_name,stu_date,stu_age,stu_sex) values ('1','zhangsan','2000-12-12 12:30:00','15','man'); commit; select * from t_stu_info;
1、日期转换成毫秒值
select UNIX_TIMESTAMP(t.stu_date) from t_stu_info t
2、毫秒值转换成日期
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(t.stu_date), '%Y-%m-%d %h:%i:%s') AS stu_date FROM t_stu_info t
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(t.stu_date), '%Y-%m-%d') AS stu_date FROM t_stu_info t
MySQL日期类型和毫秒值相互转换
标签:mysql 日期转换成毫秒值 毫秒值转换成日期
懂视网 时间:2022-04-29 21:08
现在,新建一张数据库表t_stu_info,并向表里插入数据
use test; show tables; create table t_stu_info( id int not null primary key, stu_name varchar(20), stu_date timestamp, stu_age int(3), stu_sex varchar(5) ); insert into t_stu_info(id,stu_name,stu_date,stu_age,stu_sex) values ('1','zhangsan','2000-12-12 12:30:00','15','man'); commit; select * from t_stu_info;
1、日期转换成毫秒值
select UNIX_TIMESTAMP(t.stu_date) from t_stu_info t
2、毫秒值转换成日期
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(t.stu_date), '%Y-%m-%d %h:%i:%s') AS stu_date FROM t_stu_info t
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(t.stu_date), '%Y-%m-%d') AS stu_date FROM t_stu_info t
MySQL日期类型和毫秒值相互转换
标签:mysql 日期转换成毫秒值 毫秒值转换成日期
热心网友 时间:2022-04-29 18:16
1、在MySQL 数据库中,“2009-09-15 00:00:00”转化为列为长整型的函数:热心网友 时间:2022-04-29 19:34
SELECT FROM_UNIXTIME(INT);把时间戳转换成日期SELECT UNIX_TIMESTAMP('2015-01-10');把日期转成时间戳