Here you can find the source of format(format)
Date.prototype.format = function (format) { format = format || "yyyy-MM-dd"; var args = {//from ww w .ja v a2s . c o m "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() }; if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var i in args) { var n = args[i]; if (new RegExp("(" + i + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length)); } return format; };
'use strict' const fs = require('fs'); const path = require('path'); Date.prototype.format = function(format) { let o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "H+": this.getHours(), "m+": this.getMinutes(), ...
Date.prototype.format = function(format) 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), ...
Date.prototype.format = function(format) { 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() ...
Date.prototype.format = function(format) { if (format === undefined) return this.toString(); var formatSeparator = format.match(/[.\/\-\s].*?/); var formatParts = format.split(/\W+/); var result = ''; for (var i=0; i<=formatParts.length; i++) { switch(formatParts[i]) { case 'd': ...
Date.prototype.format = function(format) { 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() ...
Date.prototype.format = function(format) var monName = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; var dayName = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]; var o = { "M+" : this.getMonth() + 1, "d+" : this.getDate(), "h+" : this.getHours(), "i+" : this.getHours() + 1, ...
Date.prototype.format = function(format) { var self = this; var h = self.getHours(); var m = self.getMinutes().toString(); var s = self.getSeconds().toString(); var M = (self.getMonth() + 1).toString(); var yyyy = self.getFullYear().toString(); var yy = self.getYear().toString(); var d = self.getDate().toString(); ...
var fs = require('fs'); var readline = require('readline'); Date.prototype.format = function(format) { var o = { "M+" : this.getMonth()+1, "d+" : this.getDate(), "h+" : this.getHours(), "m+" : this.getMinutes(), "s+" : this.getSeconds(), ...
Date.prototype.format = function(format,date){ if(!format || typeof format !== 'string'){ throw new Error('format is undefiend or type is Error'); date = date instanceof Date? date : (typeof date === 'number'|| typeof date === 'string')? new Date(date): new Date(); var formatReg = { 'y+': date.getFullYear(), 'M+': date.getMonth()+1, 'd+': date.getDate(), ...