function dateFormat(date, format) {
var o = {
"M+": () + 1, //month
"d+": (), //day
"h+": (), //hour
"m+": (), //minute
"s+": (), //second
"q+": ((() + 3) / 3), //quarter
"S": () //millisecond
};
//Replace yyyy with the specific year
if (/(y+)/.test(format)) {
format = (RegExp.$1, (() + "").substr(4 - RegExp.$));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = (RegExp.$1, RegExp.$ == 1 ? (("000" + o[k]).substr(("" + o[k]).length)) : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}