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);
});//from   ww w . j  a  va 2 s.co  m

Related

  1. 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()),
    ...
    
  2. toDate()
    Date.prototype.toDate = function(){
      return new Date(this.getFullYear(), this.getMonth(), this.getDate());
    
  3. 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());
    ...
    
  4. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
      var local = new Date(this);
      local.setMinutes(this.getMinutes() - this.getTimezoneOffset())
      return local.toJSON().slice(0,10);
    
  5. toDateInputValue(()
    Date.prototype.toDateInputValue = (function() {
      var local = new Date(this);
      local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
      return local.toISOString().substr(0,10);
    });
    
  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.toJSON().slice(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);
    });