MySQL日期和时间戳的转换

select now(); -- 2017-05-18 16:22:45

select UNIX_TIMESTAMP('2017-05-18')  -- 1495036800

select UNIX_TIMESTAMP('2017-05-18 16:23:21')  -- 1495095801

select UNIX_TIMESTAMP(now());-- 1495095868

select FROM_UNIXTIME(UNIX_TIMESTAMP(now())); -- 2017-05-18 16:24:56

select FROM_UNIXTIME(UNIX_TIMESTAMP(now()),'%Y-%m-%d') -- 2017-05-18

select FROM_UNIXTIME(UNIX_TIMESTAMP(now()),'%Y-%m-%d %H:%i:%s') -- 2017-05-18 16:28:22

你可能感兴趣的:(MySQL日期和时间戳的转换)