List of utility methods to do Date Format
format(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(), ... | |
format(format)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), ... | |
format(format)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() ... | |
format(format)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': ... | |
format(format)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() ... | |
format(format)Date.prototype.format = function (format) { format = format || "yyyy-MM-dd"; var args = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), ... | |
format(format)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, ... | |
format(format)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(); ... | |
format(format)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(), ... | |
format(format,date)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(), ... |