Nodejs Date Convert toYYYYMMDD()

Here you can find the source of toYYYYMMDD()

Method Source Code

/* Extended JavaScript Date library
 * Copyright 2009 Jaakko-Heikki Heusala <jheusala@iki.fi>
 * $Id: $//from   w w w  .java 2  s.c om
 */

/** Get date as a string in a format YYYYMMDD */
Date.prototype.toYYYYMMDD = function() {
    return this.getFullYear() + String(this.getMonth()+1).lpad(2, "0") + String(this.getDate()).lpad(2, "0");
}

Related

  1. toTime()
    Date.prototype.toTime = function () {
        var hours = this.getHours();
        var minutes = this.getMinutes();
        if (minutes < 10)
            minutes = "0" + minutes;
        if (hours < 10)
            hours = "0" + hours;
        return hours + ':' + minutes;
    };
    ...
    
  2. toTimeInputValue(()
    Date.prototype.toTimeInputValue = (function() {
      var local = new Date(this);
      local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
      return local.toJSON().slice(11,19);
    });
    
  3. toTurkishFormatDate(format)
    Date.prototype.toTurkishFormatDate = function(format) {
        var date = this,
                day = date.getDate(),
                weekDay = date.getDay(),
                month = date.getMonth() + 1,
                year = date.getFullYear(),
                hours = date.getHours(),
                minutes = date.getMinutes(),
                seconds = date.getSeconds();
    ...
    
  4. toUniversalDate()
    Date.prototype.toUniversalDate = function() {
        var localTime = this.getTime();
        var localOffset = this.getTimezoneOffset() * 60000;
        return new Date(localTime + localOffset);
    };
    
  5. toUnixTime()
    Date.prototype.toUnixTime = function() {
        return Math.round(this.getTime() / 1000);
    };
    
  6. toYmdHis()
    Date.prototype.toYmdHis = function() {
        return this.getFullYear() + "-" + twoDigits(1 + this.getMonth()) + "-" + twoDigits(this.getDate()) + " " + twoDigits(this.getHours()) + ":" + twoDigits(this.getMinutes()) + ":" + twoDigits(this.getSeconds());
    };
    
  7. to_DMY()
    Date.prototype.to_DMY = function(){
        return Util.leadingzero(this.getDate()) + '/' + Util.leadingzero(this.getMonth() + 1) + '/' + this.getFullYear()
    };
    
  8. to_datetimepicker_format()
    Date.prototype.to_datetimepicker_format = function() {
        var Y = this.getUTCFullYear();
        var M = this.getUTCMonth() + 1;
        var D = this.getUTCDate();
        var h = this.getUTCHours();
        var m = this.getUTCMinutes();
        return Y + "-" + M.pad() + "-" + D.pad() + " " + h.pad() + ":" + m.pad();
    
  9. tojson()
    Date.prototype.tojson = function() {
        var UTC = Date.printAsUTC ? 'UTC' : '';
        var year = this['get'+UTC+'FullYear']().zeroPad(4);
        var month = (this['get'+UTC+'Month']() + 1).zeroPad(2);
        var date = this['get'+UTC+'Date']().zeroPad(2);
        var hour = this['get'+UTC+'Hours']().zeroPad(2);
        var minute = this['get'+UTC+'Minutes']().zeroPad(2);
        var sec = this['get'+UTC+'Seconds']().zeroPad(2);
        if (this['get'+UTC+'Milliseconds']())
    ...