2019独角兽企业重金招聘Python工程师标准>>>  
public static void main(String[] args) throws Exception{SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//		long timeStart=sdf.parse("2011-09-20 12:30:45").getTime();long timeStart=1492775948000L;System.out.println(timeStart);Date date = new Date(timeStart);System.out.println(sdf.format(date));//		//2017-05-12 22:11:25
//		String ss = "2017-05-12 22:11:25";
//		long l=sdf.parse(ss).getTime();
//		System.out.println(l);//1494598285000
//		
//		long timeStart2=1494598285000L;
//		Date date2 = new Date(timeStart2);
//		System.out.println(sdf.format(date2));//yyyy-MM-dd HH:mm:ss.SSS
//    	1494059400 000
//    	2017-05-06 16:30:00
//    	1494059460 000
//    	2017-05-06 16:31:00//60000   ms//60 s//SELECT m.*,((now()-m.createTime)/1000) as time,SYSDATE() as sysdate, (SYSDATE()-date_format('2017-05-13 14:38:00', '%Y%m%d%H%i%s')) as test FROM tbl_hbb_resource_video_info r,tbl_hbb_mobile_live_info m where r.resourceId=m.resourceId and m.startTime is null and ((now()-m.createTime)>0) and r.STATUS = '1'//SELECT m.*,((now()-m.createTime)/1000) as time,SYSDATE() as sysdate, (SYSDATE()-date_format('2017-05-12 22:11:25', '%Y%m%d%H%i%s')) as test FROM tbl_hbb_resource_video_info r,tbl_hbb_mobile_live_info m where r.resourceId=m.resourceId and m.startTime is null and ((now()-m.createTime)>0) and r.STATUS = '1'}
SELECT m.*,((now()-m.createTime)/1000) as time,SYSDATE() as sysdate, (SYSDATE()-date_format('2017-05-13 14:38:00', '%Y%m%d%H%i%s')) as test FROM tbl_hbb_resource_video_info r,tbl_hbb_mobile_live_info m where r.resourceId=m.resourceId and m.startTime is null and ((now()-m.createTime)>0) and r.STATUS = '1'SELECT m.*,((now()-m.createTime)/1000) as time,SYSDATE() as sysdate, (SYSDATE()-date_format('2017-05-12 22:11:25', '%Y%m%d%H%i%s')) as test FROM tbl_hbb_resource_video_info r,tbl_hbb_mobile_live_info m where r.resourceId=m.resourceId and m.startTime is null and ((now()-m.createTime)>0) and r.STATUS = '1'select timestampdiff(hour,'2008-08-08 12:00:00','2008-08-08 00:00:00'); -- -12select timestampdiff(hour,'2008-08-08 00:05:00','2008-08-08 00:00:00'); -- 0select timestampdiff(minute,'2008-08-08 00:05:30','2008-08-08 00:00:00'); -- 5select timestampdiff(second,'2008-08-08 00:05:00','2008-08-08 00:00:00'); -- 300SELECT m.*,((now()-m.createTime)/1000) as time,SYSDATE() as sysdate,timestampdiff(second,SYSDATE(),m.createTime) as ss, (SYSDATE()-date_format('2017-05-12 22:11:25', '%Y%m%d%H%i%s')) as test FROM tbl_hbb_resource_video_info r,tbl_hbb_mobile_live_info m where r.resourceId=m.resourceId and m.startTime is null and ((now()-m.createTime)>0) and r.STATUS = '1'
注意:
(SYSDATE()-date_format('2017-05-12 22:11:25', '%Y%m%d%H%i%s'))
是按照 每一位去 减的
例如
当前时间是 2017-05-13 13:40:25
(SYSDATE()-date_format('2017-05-13 13:38:00', '%Y%m%d%H%i%s'))
计算出来是 225 其实 是 分钟 和 秒数 分别减的, 2 、 25