Nodejs Date Get getW3CDTF()

Here you can find the source of getW3CDTF()

Method Source Code

Date.prototype.getW3CDTF = function() {
    var year = this.getFullYear();
    var mon  = this.getMonth()+1;
    var day  = this.getDate();
    var hour = this.getHours();
    var min  = this.getMinutes();
    var sec  = this.getSeconds();
    if ( mon  < 10 ) mon  = "0"+mon;
    if ( day  < 10 ) day  = "0"+day;
    if ( hour < 10 ) hour = "0"+hour;
    if ( min  < 10 ) min  = "0"+min;
    if ( sec  < 10 ) sec  = "0"+sec;

    var tzos = this.getTimezoneOffset();
    var tzhour = tzos / 60;
    var tzmin  = tzos % 60;
    var tzpm = ( tzhour > 0 ) ? "-" : "+";
    if ( tzhour < 0 ) tzhour *= -1;
    if ( tzhour < 10 ) tzhour = "0"+tzhour;
    if ( tzmin   < 10 ) tzmin  = "0"+tzmin;

    var dtf = year+"-"+mon+"-"+day+"T"+hour+":"+min+":"+sec+tzpm+tzhour+":"+tzmin;
    return dtf;//from  w ww  .  j  a va  2s  .co  m
}

Related

  1. getSecondsTwoDigits()
    Date.prototype.getSecondsTwoDigits = function()
        var retval = this.getSeconds();
        if (retval < 10)
            return ("0" + retval.toString());
        else
            return retval.toString();
    };
    
  2. getSimpleMillisecondsgetSimpleMilliseconds()
    Date.prototype.getSimpleMilliseconds = function getSimpleMilliseconds() {
      return (this.getDaySeconds()/ (24*60*60) * (10*100*100)) - this.getDaySimpleSeconds();
    
  3. getSimpleSecondsgetSimpleSeconds()
    Date.prototype.getSimpleSeconds = function getSimpleSeconds() {
      var ss_ofs = this.getDaySimpleSeconds();
      var sm_ofs = Math.floor(ss_ofs/100);
      var sh_ofs = Math.floor(sm_ofs/100);
      return ss_ofs - sm_ofs*100;
    
  4. getStDate(strDate)
    Date.prototype.getStDate=function(strDate) {
        var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
            function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
        return date;
    };
    
  5. getSuffix()
    Date.prototype.getSuffix = function () {
        switch (this.getDate()) {
            case 1:
            case 21:
            case 31:
                return "st";
            case 2:
            case 22:
                return "nd";
    ...
    
  6. getYmd()
    Date.prototype.getYmd = function(){
       return this.getFullYear() + '-' + (this.getMonth() < 10 ? '0' : '') + this.getMonth() + '-' + (this.getDay() < 10 ? '0': '') + this.getDay();