您好,欢迎访问一九零五行业门户网

格式化Json传递日期的方法

自定义日期类型转化函数changedateformat,将//date(1294499956278+0800)//形式的函数转化为2014-5-2形式
function changedateformat(jsondate) { jsondate = jsondate.replace("/date(", "").replace(")/", ""); if (jsondate.indexof("+") > 0) { jsondate = jsondate.substring(0, jsondate.indexof("+")); } else if (jsondate.indexof("-") > 0) { jsondate = jsondate.substring(0, jsondate.indexof("-")); } var date = new date(parseint(jsondate, 10)); var month = date.getmonth() + 1 < 10 ? "0" + (date.getmonth() + 1) : date.getmonth() + 1; var currentdate = date.getdate() < 10 ? "0" + date.getdate() : date.getdate(); return date.getfullyear() + "-" + month + "-" + currentdate; }
以上就是格式化json传递日期的方法的详细内容。
其它类似信息

推荐信息