How To Get Date In Format Yyyy-mm-dd In Javascript?
I have date in format: Thu, 01 Dec 2016 00:00:00 GMT, how to get date of format yyyy-mm-dd from that?
Solution 1:
If you want to stick to plain JS:
Date.prototype.yyyymmdd = function() {
var mm = this.getMonth() + 1;
var dd = this.getDate();
return [this.getFullYear(),
(mm>9 ? '' : '0') + mm,
(dd>9 ? '' : '0') + dd
].join('-');
};
Post a Comment for "How To Get Date In Format Yyyy-mm-dd In Javascript?"