发布网友 发布时间:2024-04-03 07:03
共4个回答
热心网友 时间:2024-07-22 21:23
将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");
热心网友 时间:2024-07-22 21:21
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;
}
这个来试试
热心网友 时间:2024-07-22 21:27
ISO Date Format is not supported in Internet Explorer 8 standards mode and Quirks mode.
判断浏览器自己写格式化吧
参考:http://blog.csdn.net/hemingwang0902/article/details/4511130
热心网友 时间:2024-07-22 21:23
html网页可以参考W3C标准 http://www.w3school.com.cn/w3c/w3c_html.asp