/**
* 事件处理类
* type
*
* 1 => 2018-5-22 16:35:56
* 2 => 2018-5-22
* 3 => 2018年5月22日 16:35:56
* 4 => 2018年5月22日 16:35:56
* 5 => 2018/5/22 16:35:56
* 6 => 2018/5/22
* 7 => 2018.5.22 16:35:56
* 8 => 2018.5.22
*/
//时间戳转时间类型
function timeStampTurnTime(timeStamp, type){
type= type||1
if(timeStamp > 0){
var date = new Date();
date.setTime(timeStamp * 1000);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
switch (type){
case 1:
return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
break;
case 2:
return y + '-' + m + '-' + d;
break;
case 3:
return y + '年' + m + '月' + d+'日 '+h+':'+minute+':'+second;
break;
case 4:
return y + '年' + m + '月' + d+'日';
break;
case 5:
return y + '/' + m + '/' + d+' '+h+':'+minute+':'+second;
break;
case 6:
return y + '/' + m + '/' + d;
break;
case 7:
return y + '.' + m + '.' + d+' '+h+':'+minute+':'+second;
break;
case 8:
return y + '.' + m + '.' + d;
break;
}
}else{
return "";
}
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!