function getDateFromUrl(url)
{
var urlDateString = url.substring(url.lastIndexOf('/day/')+5);
urlDateString =urlDateString.replace("/index-1.html","");
urlDateString =urlDateString.replace("th","");
urlDateString =urlDateString.replace("rd","");
urlDateString =urlDateString.replace("st","");
urlDateString =urlDateString.replace(","," ");
urlDateString =urlDateString.replace("/"," ");
urlDateString =urlDateString.replace("-"," ");
urlDateString =urlDateString.replace("."," ");
urlDateString =urlDateString.replace(","," ");
urlDateString =urlDateString.replace("/"," ");
urlDateString =urlDateString.replace("-"," ");
urlDateString =urlDateString.replace("."," ");
return new Date(urlDateString);
}
function getDayFromDate(dt)
{
switch (dt.getDay())
{
case 0:
x="Sunday";
break;
case 1:
x="Monday";
break;
case 2:
x="Tuesday";
break;
case 3:
x="Wednesday";
break;
case 4:
x="Thursday";
break;
case 5:
x="Friday";
break;
case 6:
x="Saturday";
break;
}
return x;
}
IE和Opera不支持此脚本。因为他们不输出日期,而chrome和firefox输出日期。是不是因为他们不支持字符串格式的日期。如果是,那么日期必须是哪种格式。
输入看起来像C:\ example \ day \ 12-October-12输出应该是日期:2012年10月12日日:星期五代码是atm的方式它适用于chrome和firefox
任何帮助表示感谢。
答案 0 :(得分:0)
使用以下格式之一进行跨浏览器Date
构建:
"2010"
"2010-06"
"2010-06-09"
"2010-06-09T15:20:00Z"
"2010-06-09T15:20:00-07:00"
"2010/06/09"
"2009/6/9"
"2010/6/9 12:34"
"2010/6/9 12:34:56"
"June 9, 2010"
"2010 June 9"