Date format without time - Node.js Date

Node.js examples for Date:Date Format

Description

Date format without time

Demo Code


Date.prototype.toYMD = function () {
    return this.getFullYear() + '-' + (this.getMonth() + 1).toZeroPaddedString(2) + '-' + this.getDate().toZeroPaddedString(2);
};

Date.prototype.toCalendarDate = function () {
    return { 'day':this.getDate(), 'month':this.getMonth(), 'year':this.getFullYear()};
};

Date.prototype.withoutTimeOfDay = function () {
    return new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0, 0);
};

Related Tutorials