Javascript Date toFormattedString(include_time, interval)

Description

Javascript Date toFormattedString(include_time, interval)


// Formats date and time as "01 January 2000 17:00"
Date.prototype.toFormattedString = function(include_time, interval)
{
   str = Date.padded2(this.getDate()) + " " + Date.months[this.getMonth()] + " " + this.getFullYear();
   if (include_time) { str += " " + this.getHours() + ":" + this.getPaddedMinutes(interval) }
   return str;//  w  w  w.j  a va 2 s . co  m
}

Javascript Date toFormattedString(include_time, interval)

// Formats date and time as "2000.01.20 17:00"
Date.prototype.toFormattedString = function(include_time, interval)
{
   str = this.getFullYear() + "." + Date.padded2(this.getMonth()+1) + "." + Date.padded2(this.getDate());
   if (include_time) { str += " " + this.getHours() + ":" + this.getPaddedMinutes(interval) }
   return str;/*from  ww w .ja v a  2  s  . c om*/
}



PreviousNext

Related