Nodejs Date Convert toDateInputValue(()

Here you can find the source of toDateInputValue(()

Method Source Code

Date.prototype.toDateInputValue = (function() {
   var local = new Date(this);
   local.setMinutes(this.getMinutes() - this.getTimezoneOffset())
   return local.toJSON().slice(0,10);
}

Related

  1. toApiDate()
    function twoDigits(d) {
        if(0 <= d && d < 10) return "0" + d.toString();
        if(-10 < d && d < 0) return "-0" + (-1*d).toString();
        return d.toString();
    Date.prototype.toApiDate = function() {
        return this.getUTCFullYear() + "" + twoDigits(1 + this.getUTCMonth()) + "" + twoDigits(this.getUTCDate()); 
    };
    Date.prototype.toTrDate = function() {
    ...
    
  2. toCommonCase()
    Date.prototype.toCommonCase=function(){
        var xYear=this.getYear();
        xYear=xYear+1900;
        var xMonth=this.getMonth()+1;
        if(xMonth<10){
            xMonth="0"+xMonth;
        var xDay=this.getDate();
        if(xDay<10){
    ...
    
  3. toCustomFormat()
    var prependZero = function(num) {
      return (num < 10)? ("0" + num) : num;
    Date.prototype.toCustomFormat = function() {
      var h = this.getHours(),
          h_12hr = (h % 12),
          hh = prependZero((h_12hr == 0)? 12 : h_12hr),
          mm = prependZero(this.getMinutes()),
          ss = prependZero(this.getSeconds()),
    ...
    
  4. toDate()
    Date.prototype.toDate = function(){
      return new Date(this.getFullYear(), this.getMonth(), this.getDate());
    
  5. toDateFormat(format)
    Date.prototype.toDateFormat = function (format) {
        format = format || "yyyy/mm/dd";
        return format.toLowerCase()
            .replace(/yyyy/g, this.getFullYear())
            .replace(/yy/g, this.getYear())
            .replace(/mm/g, this.getMonth2())
            .replace(/m/g, this.getMonth() + 1)
            .replace(/dd/g, this.getDate2())
            .replace(/d/g, this.getDate());
    ...
    
  6. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
      var local = new Date(this);
      local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
      return local.toISOString().substr(0,10);
    });
    
  7. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
        var local = new Date(this);
        local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
        return local.toJSON().slice(0,10);
    });
    
  8. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
      var local = new Date(this);
      local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
      return local.toISOString().substr(0,10);
    });
    
  9. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
        var local = new Date(this);
        local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
        return local.toJSON().slice(0,10);
    });