Return to Snippet

Revision: 44696
at April 15, 2011 22:07 by madr


Initial Code
function adate(daysFromNow) {
  var date, datestr, mm, dd;
  
  datestr = new Date().getTime();
  
  if (!!daysFromNow) {
    datestr += (1000 * 60 * 60 * 24 * daysFromNow);
  }
  
  date = new Date(datestr);
  
  mm = date.getMonth() + '';
  if (mm.length == 1) {
    mm = '0' + mm;
  }
  
  dd = date.getDate() + '';
  if (dd.length == 1) {
    dd = '0' + dd;
  }
  
  return date.getFullYear() + '-' + 
         mm +  '-' + dd;
}

Initial URL

                                

Initial Description

                                

Initial Title
Generate readable date function, with optional date diff

Initial Tags
javascript, date, textmate

Initial Language
Other