Nodejs String to Date Convert getDateString(str)

Here you can find the source of getDateString(str)

Method Source Code

Date.prototype.getDateString = function(str)
{
  var dnames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
      'Thursday', 'Friday', 'Saturday', 'Sunday'];

  var mnames = ['January', 'February', 'March', 'April',
      'May', 'June', 'July', 'August', 'September',
      'October', 'Novemeber', 'December'];

  str = str.replace('%day', dnames[this.getDay()]);
  str = str.replace('%date', this.getDate());
  str = str.replace('%ordinal', this.getDateOrdinal());
  str = str.replace('%month', mnames[this.getMonth()]);
  str = str.replace('%year', this.getFullYear());

  return str;//from w  w  w  . j  av a 2s.co m
};

Related

  1. toDateFromAspNet()
    String.prototype.toDateFromAspNet = function () {
        var dte = eval("new " + this.replace(/\
        dte.setMinutes(dte.getMinutes() - dte.getTimezoneOffset());
        return dte;
    };
    
  2. getDate()
    String.prototype.getDate = function() {
        return this.toDate().getDate();
    
  3. getDateString()
    Date.prototype.getDateString = function(){
      var S = this.getSeconds(),
          M = this.getMinutes(), H = this.getHours(),
          dd = this.getDate(), mm = this.getMonth()+1, 
          yyyy = this.getFullYear();
      if(dd<10){
        dd ='0'+dd
      if(mm<10) {
    ...
    
  4. getDateString()
    Date.prototype.getDateString = function () {
       return this.getFullYear() + '/' + this.getMonth2() + '/' + this.getDate2();
    };
    Date.prototype.addDays = function (days) {
        this.setDate(this.getDate() + days);
        return this;
    };
    Date.prototype.getDate2 = function () {
       var date = this.getDate();
    ...
    
  5. getDateString()
    Date.prototype.getDateString = function () {
       return this.getFullYear() + '/' + this.getMonth2() + '/' + this.getDate2();
    };