一、MySql时间戳转换
select unix_timestamp(); #获取时间戳格式时间
select FROM_UNIXTIME(1717399499); #将时间戳转换为普通格式时间
二、Mysql时间相加减结果转换为秒
方法1:time_to_sec(timediff(endTime, startTime))
SELECTDISTINCT(column1),min(last_modified_time),max(last_modified_time),time_to_sec(timediff(max(last_modified_time), min(last_modified_time))) as time1
FROMtable1
wherecolumn1 = 'aaa';
方法2:timestampdiff(second, startTime, endTime)
SELECTDISTINCT(column1),min(last_modified_time),max(last_modified_time),timestampdiff(second,min(last_modified_time),max(last_modified_time)) as time2
FROMtable1
wherecolumn1 = 'aaa';
方法3:unix_timestamp(endTime) -unix_timestamp(startTime)
SELECTDISTINCT(column1),min(last_modified_time),max(last_modified_time),unix_timestamp(max(last_modified_time)) - unix_timestamp(min(last_modified_time)) as time3
FROMtable1
wherecolumn1 = 'aaa';
三、Mysql时间相加减结果为时分秒
方法:timediff(time1,time2)
SELECTcolumn1,max(last_modified_time),min(last_modified_time),timediff(max(last_modified_time),min(last_modified_time))
FROMtable1
wherecolumn1 = 'aaa';