-2

I have the next in js, in order to file the date before 29 days:

    var d = new Date();
    d.setDate(d.getDate() - 29);
    console.log(d);

and it return:

Sat Nov 22 2014 07:32:22 GMT-0500 (EST)

I want that it will return the following:

11-22-14

there is any way to do it?

Or Smith
  • 3,376
  • 12
  • 37
  • 64

1 Answers1

-1
console.log((d.getMonth()+1)+'-'+d.getDate()+'-'+d.getFullYear().toString().slice(-2));
Scimonster
  • 31,931
  • 8
  • 74
  • 86