js日期转换格式的方法ie不支持,提示对象不支持此属性或方法,求解决方法。。。火狐、360都没问题的。。
发布网友
发布时间:2022-04-30 07:21
我来回答
共4个回答
热心网友
时间:2023-10-21 04:58
将getFormatDate函数改成如下:
function getFormatDate(date, pattern) {
if (date == undefined) {
date = new Date();
}
var Year= date.getFullYear();
var Month= date.getMonth()+1;
var Day = date.getDate();
var Hour=date.getHours();
var Minute=date.getMinutes();
var Second=date.getSeconds();
if (pattern == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
}
return pattern.replace("yyyy",Year).replace("MM",Month).replace("DD", Day).replace("HH",Hour).replace("mm",Minute).replace("ss", Second);
}
//调用方式
getFormatDate(new Date(), "yyyy年MM月DD日 HH:mm:ss");
热心网友
时间:2023-10-21 04:58
function getNowFormatDate()
{
var day = new Date();
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
//初始化时间
//Year= day.getYear();//有火狐下2008年显示108的bug
Year= day.getFullYear();//ie火狐下都可以
Month= day.getMonth()+1;
Day = day.getDate();
//Hour = day.getHours();
// Minute = day.getMinutes();
// Second = day.getSeconds();
CurrentDate += Year + "-";
if (Month >= 10 )
{
CurrentDate += Month + "-";
}
else
{
CurrentDate += "0" + Month + "-";
}
if (Day >= 10 )
{
CurrentDate += Day ;
}
else
{
CurrentDate += "0" + Day ;
}
return CurrentDate;
}
这个来试试
追问我对这个不太了解的,那我要如何放参数AddTime
呢?
热心网友
时间:2023-10-21 04:59
ISO Date Format is not supported in Internet Explorer 8 standards mode and Quirks mode.
判断浏览器自己写格式化吧
参考:http://blog.csdn.net/hemingwang0902/article/details/4511130
热心网友
时间:2023-10-21 04:59
html网页可以参考W3C标准 http://www.w3school.com.cn/w3c/w3c_html.asp
热心网友
时间:2023-10-21 04:58
将getFormatDate函数改成如下:
function getFormatDate(date, pattern) {
if (date == undefined) {
date = new Date();
}
var Year= date.getFullYear();
var Month= date.getMonth()+1;
var Day = date.getDate();
var Hour=date.getHours();
var Minute=date.getMinutes();
var Second=date.getSeconds();
if (pattern == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
}
return pattern.replace("yyyy",Year).replace("MM",Month).replace("DD", Day).replace("HH",Hour).replace("mm",Minute).replace("ss", Second);
}
//调用方式
getFormatDate(new Date(), "yyyy年MM月DD日 HH:mm:ss");
热心网友
时间:2023-10-21 04:58
function getNowFormatDate()
{
var day = new Date();
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
//初始化时间
//Year= day.getYear();//有火狐下2008年显示108的bug
Year= day.getFullYear();//ie火狐下都可以
Month= day.getMonth()+1;
Day = day.getDate();
//Hour = day.getHours();
// Minute = day.getMinutes();
// Second = day.getSeconds();
CurrentDate += Year + "-";
if (Month >= 10 )
{
CurrentDate += Month + "-";
}
else
{
CurrentDate += "0" + Month + "-";
}
if (Day >= 10 )
{
CurrentDate += Day ;
}
else
{
CurrentDate += "0" + Day ;
}
return CurrentDate;
}
这个来试试
追问我对这个不太了解的,那我要如何放参数AddTime
呢?
热心网友
时间:2023-10-21 04:59
ISO Date Format is not supported in Internet Explorer 8 standards mode and Quirks mode.
判断浏览器自己写格式化吧
参考:http://blog.csdn.net/hemingwang0902/article/details/4511130
热心网友
时间:2023-10-21 04:59
html网页可以参考W3C标准 http://www.w3school.com.cn/w3c/w3c_html.asp