Nodejs String Format toFormattedString(include_time)

Here you can find the source of toFormattedString(include_time)

Method Source Code

Date.prototype.toFormattedString = function(include_time) {
  var str = this.getFullYear() + '-' + Date.padded2(this.getMonth() + 1) + '-' + Date.padded2(this.getDate());
  return str;// w  w  w.j  av  a 2s  .co  m
}

Related

  1. format()
    function format () {
      if (arguments.length === 0) return this;
      var iter;
      if (arguments.length > 1) { 
        iter = arguments;
      } else {
        iter = arguments[0];
      var ret = this;
    ...
    
  2. format()
    (function(){
    function format () {
      if (arguments.length === 0) return this;
      var iter;
      if (arguments.length > 1) { 
        iter = arguments;
      } else {
        iter = arguments[0];
      var ret = this;
      for (var i in iter) {
        ret = ret.replace('{'+i+'}', iter[i]);
      return ret;
    String.prototype.format = format;
    })();
    
  3. toFormattedString(f)
    Date.prototype.toFormattedString = function (f) {
        var nm = this.getMonthName();
        var nd = this.getDayName();
        f = f.replace(/yyyy/g, this.getFullYear());
        f = f.replace(/yy/g, String(this.getFullYear()).substr(2, 2));
        f = f.replace(/MMM/g, nm.substr(0, 3).toUpperCase());
        f = f.replace(/Mmm/g, nm.substr(0, 3));
        f = f.replace(/MM\*/g, nm.toUpperCase());
        f = f.replace(/Mm\*/g, nm);
    ...
    
  4. toFormattedString(f)
    Date.prototype.toFormattedString = function(f) {
        f = f.replace(/yyyy/g, this.getFullYear());
        f = f.replace(/yy/g, String(this.getFullYear()).substr(2, 2));
        f = f.replace(/mm/g, String(this.getMonth() + 1).padLeft('0', 2));
        f = f.replace(/dd/g, String(this.getDate()).padLeft('0', 2));
        f = f.replace(/HH/g, String(this.getHours()).padLeft('0', 2));
        f = f.replace(/MM/g, String(this.getMinutes()).padLeft('0', 2));
        return f;
    };
    ...
    
  5. toFormattedString(format)
    WScript.echo("Date Extensions Module Loaded");
    Date.prototype.toFormattedString = function (format) {
        var year = (this.getFullYear()).toString();
        var month = (1 + this.getMonth()).toString();
        var day = (this.getDate()).toString();
        month = month.length > 1 ? month : "0" + month;
        day = day.length > 1 ? day : "0" + day;
        switch (format) {
            case "YYYYMMDD": return year + month + day; break;
    ...
    
  6. toFormattedString(include_time)
    Date.prototype.toFormattedString = function(include_time)
       str = this.getFullYear() + "." + Date.padded2(this.getMonth()+1) + "." + Date.padded2(this.getDate());
       if (include_time) { str += " " + this.getHours() + ":" + this.getPaddedMinutes() }
       return str;
    
  7. toFormattedString(include_time)
    Date.prototype.toFormattedString = function(include_time)
       str = Date.padded2(this.getDate()) + " " + Date.months[this.getMonth()] + " " + this.getFullYear();
       if (include_time) { str += " " + this.getHours() + ":" + this.getPaddedMinutes() }
       return str;
    
  8. toFormattedString(include_time)
    Date.prototype.toFormattedString = function(include_time)
      var str = Date.padded2(this.getDate()) + "/" + Date.padded2(this.getMonth() + 1) + "/" + this.getFullYear();
      return str;
    
  9. toFormattedString(include_time)
    Date.prototype.toFormattedString = function(include_time){
      str = this.getDate() + "/" + (this.getMonth() + 1) + "/" + this.getFullYear();
      if (include_time) { str += " " + this.getHours() + ":" + this.getPaddedMinutes() }
      return str;
    Date.parseFormattedString = function (string) {
      var regexp = '([0-9]{1,2})/(([0-9]{1,2})/(([0-9]{4})( ([0-9]{1,2}):([0-9]{2})? *)?)?)?';
      var d = string.match(new RegExp(regexp, "i"));
      if (d==null) return Date.parse(string); 
    ...