0

How do I return yesterday day in the format of yyyy-mm-dd using JavaScript and using the regular expression below.

((19|20)\d\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])
Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64

1 Answers1

0

Native JS date formatting is very primitive (see this question for more details).

If you can, a better solution is to use Moment.js to make working with dates in JS much, much better.

Community
  • 1
  • 1
GregL
  • 37,147
  • 8
  • 62
  • 67