用自己的js代码介绍代码:
复制代码代码如下所示:
date.prototype.format =函数(格式)
{
var { { { {
M +:this.getmonth()+ 1, / /月
D:this.getdate(), / /天
H:this.gethours(), / /小时
M +:this.getminutes(), / /分钟
+:this.getseconds(), / /二
Q+:Math.floor(((this.getmonth()+ 3)/ 3), / /季度
S:this.getmilliseconds() / /毫秒
};
如果((y +)测试(格式))
{
格式= format.replace(regexp。1美元,((this.getfullyear()+)。Substr(4—9。1美元。长度));
}
对于(k在O中k)
{
如果(新规则((钾))。试验(格式))
{
格式= format.replace(regexp。1美元,regexp。1美元。长度= = 1 O { }:K(00 + O { k })。Substr((+ O { k })。长度));
}
}
Return format;
};


调用的方法如下所示:

新日期();
无功nowdate = dt.format(yyyy-mm-dd HH:毫米:SS );

你可以获得当前时间:2013-12-02 14:02:11