- bigint转date
mysql内置函数unix_timestamp(),将datetime转为bigint
-- date转bigint insert into ks_msg(user_Id,username,creatime) VALUES(123,"bignit",unix_timestamp(NOW())) -- bigint转date select from_unixtime(bigint/1000) select from_unixtime(bigint/1000,'%Y-%m-%d')
- date转bigint
from_unixtime()函数可以将bigint值转换为日期,返回值是以秒为单位
-- date转bigint UNIX_TIMESTAMP('2017-05-19 17:01:31'); -- bigint转date select from_unixtime(creatime/1000) from ks_msg where id = '2'