function strlen(str) { var len = 0; for (var i = 0; i < str.length; i++) { var c = str.charCodeAt(i); //单字节加1 if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { len++; } else { len += 2; } } return len; } function Todate(num) { //Fri Oct 31 18:00:00 UTC+0800 2008 Wed Jul 15 2015 00:00:00 GMT+0800 num = num + ""; var date = ""; var month = new Array(); month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6; month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12; var week = new Array(); week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四"; week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日"; str = num.split(" "); date = str[3] + "-"; var count = strlen(month[str[1]]); var m = month[str[1]]; if (count = 1) { m = "0" + month[str[1]]; } date = date + m + "-" + str[2]; return date; }
方法Todate(参数) 参数格式:Wed Jul 15 2015 00:00:00 GMT+0800
时间: 2024-09-28 15:47:51