格式化json日期格式對象
調用toDate(timeString)
/**
* 時間對象的格式化
*/
Dateprototypeformat = function(format) {
/*
* format=yyyyMMdd hh:mm:ss;
*/
var o = {
M+ : thisgetMonth() +
d+ : thisgetDate()
h+ : thisgetHours()
m+ : thisgetMinutes()
s+ : thisgetSeconds()
q+ : Mathfloor((thisgetMonth() + ) / )
S : thisgetMilliseconds()
}
if (/(y+)/test(format)) {
format = formatreplace(RegExp$ (thisgetFullYear() + )substr(
RegExp$length))
}
for (var k in o) {
if (new RegExp(( + k + ))test(format)) {
format = formatreplace(RegExp$ RegExp$length ==
? o[k]
: ( + o[k])substr(( + o[k])length))
}
}
return format;
}
//{date:day:hours:minutes:month:seconds:time:timezoneOffset:year:}
function toDate(obj){
var date = new Date()
datesetTime(objtime)
datesetHours(objhours)
datesetMinutes(objminutes)
datesetSeconds(objseconds)
return dateformat(yyyyMMdd hh:mm:ss)
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19479.html