// 设置时间格式 2016-10-20 17:41:03
function getNowFormatDate(timeDate){
var date = new Date(timeDate);
var seperator1 = "-";
var seperator2 = ":";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
var hours = date.getHours();
var mins = date.getMinutes();
var ms = date.getSeconds();
if (month >=1 && month <=9){
month = '0' + month;
}
if (strDate >= 1 && strDate <= 9){
strDate = '0' + strDate;
}
if (hours >= 0 && hours <=9){
hours = '0' + hours;
}
if (mins >= 0 && mins <=9){
mins = '0' + mins;
}
if (ms >= 0 && ms <=9){
ms = '0' + ms;
}
var currentdate = year + seperator1 + month + seperator1 + strDate
+ " " + hours + seperator2 + mins + seperator2 + ms;
return currentdate;
}
// 时间格式化
function timeFormat(timeDate, type){
if("" == timeDate || null == timeDate){
return "";
}
else if ("mins" == type){
return timeDate / 60 / 1000;
}
else if ("date" == type){
return getNowFormatDate(timeDate);
}
else{
return timeDate;
}
};
日期时间格式化
最新推荐文章于 2024-10-03 22:03:27 发布