Here are useful one-liners to get date string in various formats:
US-Date formatted as m/d/yyyy and mm/DD/yyyy (padded zeroes)
>new Date().toLocaleDateString(); //if your locale is US, otherwise toLocaleDateString('en-US');
"2/7/2020"
>new Date().toLocaleDateString('es-pa'); //zero-padded US date
"02/07/2020"
Date formatted as yyyy-mm-dd, and yyyymmdd: useful for sorting
>new Date().toLocaleDateString('en-ca');
"2020-02-07"
>new Date().toLocaleDateString('en-ca').replace(/-/g,'');
"20200207"
This list covers most other international formats:
d-M-yyyy nl
dd.MM.yyyy en-CH
d. M. yyyy sk
d.MM.yyyy pl
d.M.yyyy de
dd/MM/yyyy en-DE
d/MM/yyyy en-NZ
d/M/yyyy ca
d/M/yyyy mr (devanagari numbers)
yyyy-M-d bs
yyyy. MM. dd. hu
yyyy. M. d. ko-KP
yyyy/MM/dd en-ZA
yyyy/MM/dd ar-EG (arabic numbers)
yyyy/M/d zh-CN
Finally, the ECMAScript Intl.DateTimeFormat is the Internationalization API that gives you lot of formatting flexibility. Here is a link to the documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat