日期格式化(适用于ie,火狐)
//适用于ie以及火狐等浏览器
function toDate(date) {
if(date!=null){
var y = date.getFullYear();
var m = date.getMonth()+1;
m = m<10?'0'+m:m;
var s = date.getSeconds();
var d = date.getDate();
d = d<10?("0"+d):d;
var h = date.getHours();
h = h<10?("0"+h):h;
var M = date.getMinutes();
M = M<10?("0"+M):M;
var S = date.getSeconds();
S = S<10?("0"+S):s;
var str = y+"-"+m+"-"+d+" "+h+":"+M;
return str;
}else{
return "";
}
}
//使用
var mydate = new Date();
var formatDate = toDate(mydate);//显示的日期格式是yyyy-mm-dd hh:mm
相关推荐
九天银河技术 2020-11-11
zhangjie 2020-11-11
Crazyshark 2020-11-13
步知道 2020-10-27
tufeiax 2020-09-03
李轮清 2020-09-15
85251846 2020-09-14
wangpaiyonghu 2020-06-28
jackalwb 2020-06-14
yhljxy 2020-06-14
myveer 2020-06-14
xiaobaif 2020-06-14
klarclm 2020-06-13
songshijiazuaa 2020-06-13
TMD咯MySQL 2020-06-12
archive 2020-06-12
清风徐来水波不兴 2020-06-09