Nodejs Date Format Format(fmt)

Here you can find the source of Format(fmt)

Method Source Code

Date.prototype.Format = function(fmt) {
    var k, o, str;
    o = {//from   w w  w. ja va  2  s.  co  m
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S": this.getMilliseconds()
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (k in o) {
        if (!(new RegExp("(" + k + ")").test(fmt))) {
            continue;
        }
        if (RegExp.$1.length === 1) {
            str = o[k];
        } else {
            str = ("00" + o[k]).substr(("" + o[k]).length);
        }
        fmt = fmt.replace(RegExp.$1, str);
    }
    return fmt;
};
module.exports = Date.prototype.Format;

Related

  1. Format(fmt)
    Date.prototype.Format = function (fmt) {
        var o = {
            "m+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "i+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds()
    ...
    
  2. Format(fmt)
    Date.prototype.Format = function (fmt) {
      var o = {
        "M+": this.getMonth() + 1, 
        "d+": this.getDate(), 
        "h+": this.getHours(), 
        "m+": this.getMinutes(), 
        "s+": this.getSeconds(), 
        "q+": Math.floor((this.getMonth() + 3) / 3), 
        "S": this.getMilliseconds() 
    ...
    
  3. Format(fmt)
    Date.prototype.Format = function (fmt) { 
      var o = {
        'M+': this.getMonth() + 1,
        'd+': this.getDate(), 
        'h+': this.getHours(),
        'm+': this.getMinutes(),
        's+': this.getSeconds(),
        'q+': Math.floor((this.getMonth() + 3) / 3),
        'S': this.getMilliseconds()
    ...
    
  4. Format(fmt)
    Date.prototype.Format = function (fmt) {
      let values = {
        'M+': this.getMonth() + 1,
        'd+': this.getDate(),
        'h+': this.getHours(),
        'm+': this.getMinutes(),
        's+': this.getSeconds(),
        'q+': Math.floor((this.getMonth() + 3) / 3),
        'S': this.getMilliseconds()
    ...
    
  5. Format(fmt)
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds() 
    ...
    
  6. Format(fmt)
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, 
            "d+": this.getDate(),  
            "H+": this.getHours(), 
            "m+": this.getMinutes(), 
            "s+": this.getSeconds(), 
            "q+": Math.floor((this.getMonth() + 3) / 3), 
            "S": this.getMilliseconds()   
    ...
    
  7. Format(fmt)
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, 
            "d+": this.getDate(), 
            "h+": this.getHours(), 
            "m+": this.getMinutes(), 
            "s+": this.getSeconds(), 
            "q+": Math.floor((this.getMonth() + 3) / 3), 
            "S": this.getMilliseconds() 
    ...
    
  8. Format(fmt)
    function datecompare(date1, date2){  
        if (!date1) {
            return 1;
        if (!date2) {
            return -1;
        };
        var strdt1=date1.replace("-","/");  
        var strdt2=date2.replace("-","/");     
    ...
    
  9. Format(fmt)
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, 
            "d+": this.getDate(), 
            "h+": this.getHours(), 
            "m+": this.getMinutes(), 
            "s+": this.getSeconds(), 
            "q+": Math.floor((this.getMonth() + 3) / 3), 
            "S": this.getMilliseconds() 
    ...