MySQL毫秒值和日期转换,MYSQL内置函数FROM_UNIXTIME: select FROM_UNIXTIME(t.createDate/1000,'%Y-%m-%d %h:%i:%s') as cd from task t where taskStatus='1'; SELECT FROM_UNIXTIME(time/1000,'%Y-%m-%d %h:%i:%s') FROM `logs` where time='1541260863000'; //t.createDate里是lon
public static void main(String[] args) { String time = System.currentTimeMillis();//获取当前时间精确到毫秒级的时间戳,例:1525849325942 System.out.println(timeStamp2Date(time)) } public static String timeStamp2Date(String time) { Long timeLong = Long.parseLong(time); S
前几天,工作用到了将时间戳转化成具体的时间(年月日 时:分:秒),出了一点问题,先看一下下面的sql语句: select *,FROM_UNIXTIME(created_at,'%Y-%m-%d %H:%m:%s') as created_at from sms_history WHERE mobile ='177XXXXXXX' ; 上面这句sql是有问题的,标注部分有两个%m(自己根据自己的理解写的,Y-year,m-month,d-day,H-hour ,m-minute,s-second