jack преди 7 години
родител
ревизия
149a8578ea
променени са 2 файла, в които са добавени 59 реда и са изтрити 56 реда
  1. 30 27
      e/a.html
  2. 29 29
      js/common.js

+ 30 - 27
e/a.html

@ -279,33 +279,36 @@
279 279

280 280
					}
281 281
				});
282
function commenTime(startTime){
283
	var nowTimg =  new Date();
284
	var startdate = new Date(); 
285
	startdate.setFullYear(parseInt(startTime.substring(0,4)));
286
	startdate.setMonth(parseInt(startTime.substring(4,6))-1);
287
	startdate.setDate(parseInt(startTime.substring(6,8)));
288
	startdate.setHours(parseInt(startTime.substring(8,10)));
289
	startdate.setMinutes(parseInt(startTime.substring(10,12)));
290
	startdate.setSeconds(parseInt(startTime.substring(12,14)));
291
	var date3=nowTimg.getTime()-startdate.getTime();  //时间差的毫秒数
292
    var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
293
    var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
294
    if(date3 < 60000){
295
    	return "刚刚";
296
    }else if(date3 >= 60000 && date3 < 3600000){
297
    	return minutes + "分钟前";
298
    }else if(date3 >= 3600000 && date3 < 86400000){
299
    	return hours + "小时前";
300
    }else if(date3 >= 86400000 && date3 < 172800000){
301
    	return "昨天 " + startTime.substring(8,10) + ":" +startTime.substring(10,12);
302
    	
303
    }else if(date3 >= 172800000 && date3 < 31536000000){
304
    	return startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
305
    }
306
    else{
307
    	return startTime.substring(0,4)  + "年" + startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
308
    }
282
//时间显示规则
283
function commenTime(startTime) {
284
	console.log(startTime)
285
	var nowTimg = new Date();
286
	var startdate = new Date();
287
	startdate.setFullYear(parseInt(startTime.substring(0, 4)));
288
	startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
289
	startdate.setDate(parseInt(startTime.substring(6, 8)));
290
	startdate.setHours(parseInt(startTime.substring(8, 10)));
291
	startdate.setMinutes(parseInt(startTime.substring(10, 12)));
292
	startdate.setSeconds(parseInt(startTime.substring(12, 14)));
293
	var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
294
	var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
295
	var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
296
	if(date3 < 60000) {
297
		return "刚刚";
298
	} else if(date3 >= 60000 && date3 < 3600000) {
299
		return minutes + "分钟前";
300
	} else if(date3 >= 3600000 && date3 < 86400000) {
301
		return hours + "小时前";
302
	} else if(date3 >= 86400000) {
303

304
		if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
305

306
			return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
307
		} else {
308

309
			return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
310
		}
311
	}
309 312
}
310 313
			})
311 314
		</script>

+ 29 - 29
js/common.js

@ -502,36 +502,36 @@ $(".msgContbox textarea").focus(function(){
502 502
}).blur(function(){
503 503
	$(this).parent().css("border-color","#E5E5E5");
504 504
})
505
506 505
//时间显示规则
507
function commenTime(startTime){
508
	var nowTimg =  new Date();
509
	var startdate = new Date(); 
510
	startdate.setFullYear(parseInt(startTime.substring(0,4)));
511
	startdate.setMonth(parseInt(startTime.substring(4,6))-1);
512
	startdate.setDate(parseInt(startTime.substring(6,8)));
513
	startdate.setHours(parseInt(startTime.substring(8,10)));
514
	startdate.setMinutes(parseInt(startTime.substring(10,12)));
515
	startdate.setSeconds(parseInt(startTime.substring(12,14)));
516
	var date3=nowTimg.getTime()-startdate.getTime();  //时间差的毫秒数
517
    var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
518
    var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
519
    if(date3 < 60000){
520
    	return "刚刚";
521
    }else if(date3 >= 60000 && date3 < 3600000){
522
    	return minutes + "分钟前";
523
    }else if(date3 >= 3600000 && date3 < 86400000){
524
    	return hours + "小时前";
525
    }else if(date3 >= 86400000 && date3 < 172800000){
526
    	return "昨天 " + startTime.substring(8,10) + ":" +startTime.substring(10,12);
527
    	
528
    }else if(date3 >= 172800000 && date3 < 31536000000){
529
    	return startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
530
    }
531
    else{
532
    	return startTime.substring(0,4)  + "年" + startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
533
    }
534
  
506
function commenTime(startTime) {
507
	console.log(startTime)
508
	var nowTimg = new Date();
509
	var startdate = new Date();
510
	startdate.setFullYear(parseInt(startTime.substring(0, 4)));
511
	startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
512
	startdate.setDate(parseInt(startTime.substring(6, 8)));
513
	startdate.setHours(parseInt(startTime.substring(8, 10)));
514
	startdate.setMinutes(parseInt(startTime.substring(10, 12)));
515
	startdate.setSeconds(parseInt(startTime.substring(12, 14)));
516
	var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
517
	var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
518
	var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
519
	if(date3 < 60000) {
520
		return "刚刚";
521
	} else if(date3 >= 60000 && date3 < 3600000) {
522
		return minutes + "分钟前";
523
	} else if(date3 >= 3600000 && date3 < 86400000) {
524
		return hours + "小时前";
525
	} else if(date3 >= 86400000) {
526
527
		if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
528
529
			return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
530
		} else {
531
532
			return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
533
		}
534
	}
535 535
}
536 536
/*时间转换*/
537 537
function TimeTr(dealtime) {