Javascript将国际日期转换成本地日期的函数


JavaScript #日期 #函数2012-06-16 09:10

直接上代码:

//将国际化日期转化成本地日期yyyy-MM-dd
function f_ToDate(num) { //Fri Oct 31 18:00:00 UTC+0800 2008 
    num = num + "";
    var date = "";
    var month = new Array();
    month["Jan"] = "01"; month["Feb"] = "02"; month["Mar"] = "03"; month["Apr"] = "04"; month["May"] = "05"; month["Jun"] = "06";
    month["Jul"] = "07"; month["Aug"] = "08"; month["Sep"] = "09"; month["Oct"] = "10"; month["Nov"] = "11"; month["Dec"] = "12";
    //var week = new Array(); //http://yige.org
    //week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四"; week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
    str = num.split(" ");
    date = str[5] + "-";
    date = date + month[str[1]] + "-" + str[2];
    //date=date+" 周"+week[str[0]]; 
    return date;
}


相关文章

粤ICP备11097351号-1