Nodejs Date Format format()

Here you can find the source of format()

Method Source Code

Date.prototype.format = function () {
  'use strict';/*from   w ww  . j  av  a 2s  . co  m*/

  var
      d = this.getDate()
    , m = this.getMonth() + 1
    , y = this.getFullYear();

    return '' + y + '-' + (m<=9 ? '0' + m : m) + '-' + (d <= 9 ? '0' + d : d);
};

Related

  1. dateFormat(value)
    function dateFormat(value) {
      if (!value)
        return new Date(0);
      var pattern = /\/Date\(([0-9]+)((-|\+)[0-9]+)?\)\
      var match = pattern.exec(value.toString());
      if (!match)
        return new Date(0);
      var utc = parseInt(match[1], 10);
      var offset = (parseInt(match[2], 10) || 0) * 10 * 60 * 60; 
    ...
    
  2. format
    ===
    
  3. format( format )
    Date.prototype.format = function( format ){
        if( typeof format !== "string" ) return this.toLocaleString();
        var match = {
            "y": this.getFullYear(),
            "M": this.getMonth() + 1,
            "d": this.getDate(),
            "h": this.getHours(),
            "m": this.getMinutes(),
            "s": this.getSeconds(),
    ...
    
  4. format( format )
    define(function(require, exports, module) {
    Date.prototype.format = function( format ){
        if( typeof format !== "string" ) return this.toLocaleString();
        var match = {
            "y": this.getFullYear(),
            "M": this.getMonth() + 1,
            "d": this.getDate(),
            "h": this.getHours(),
            "m": this.getMinutes(),
    ...
    
  5. format(()
    Date.prototype.format = (function() {
      var
        that, txts,
        roman = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII'],
        addZero = function(num) {
          return num < 10 ? '0' + num : num;
        },
        na = function(n, z) {
          return n % z;
    ...
    
  6. format()
    function ISODateString(aDate) {
      function pad(aNumber) {
        return aNumber < 10 ? '0' + aNumber : aNumber;
      return aDate.getUTCFullYear() + '-' +
             pad(aDate.getUTCMonth() + 1) + '-' +
             pad(aDate.getUTCDate());
    Date.prototype.format = function () {
    ...
    
  7. format()
    function ISODateString(aDate) {
      function pad(aNumber) {
        return aNumber < 10 ? '0' + aNumber : aNumber;
      return aDate.getUTCFullYear() + '-' +
             pad(aDate.getUTCMonth() + 1) + '-' +
             pad(aDate.getUTCDate());
    Date.prototype.format = function () {
    ...
    
  8. format()
    Date.prototype.format = function() {
      var d = new Date();
      var curr_date = d.getDate();
      var curr_month = d.getMonth();
      var curr_year = d.getFullYear();
      return (curr_date + "/" + curr_month + "/" + curr_year);
    
  9. format()
    Date.prototype.format = function(){
      var formatMonth = function(month, numberOfDigits){
        month += 1;
        month = insertZerosLeft(month, numberOfDigits);
        return month;
      };
      var insertZerosLeft = function(data, numberOfDigits){
        data = data.toString();
        var zeros = '';
    ...