日期:2014-05-16 浏览次数:20419 次
function formatDate(n) { if (typeof (n) == "number") { var uom = new Date(); uom.setDate(uom.getDate() + n); var y = uom.getFullYear(); var m = (uom.getMonth() + 1); var d = uom.getDate(); m = m > 9 ? m : '0' + m; d = d > 9 ? d : '0' + d; uom = y + "-" + m + "-" + d; } if (typeof (n) == "string") { var chs = new Array(); chs = n.split("-"); var years = new Date(chs[0], chs[1] - 1, chs[2]); var strTimes = new Date(years - 0 + 1 * 86400000); var y = strTimes.getFullYear(); var m = (strTimes.getMonth() + 1); var d = strTimes.getDate(); m = m > 9 ? m : '0' + m; d = d > 9 ? d : '0' + d; uom = y + "-" + m + "-" + d; } return uom; }