Altered piece of code I often use:
(我经常使用的修改过的代码:)
Date.prototype.yyyymmdd = function() {
var mm = this.getMonth() + 1; // getMonth() is zero-based
var dd = this.getDate();
return [this.getFullYear(),
(mm>9 ? '' : '0') + mm,
(dd>9 ? '' : '0') + dd
].join('');
};
var date = new Date();
date.yyyymmdd();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…