I\'m trying to use JS to turn a date object into a string in YYYYMMDD format. Is there an easier way than concatenating Date.getYear()
date object
YYYYMMDD
Date.getYear()
new Date('Jun 5 2016'). toLocaleString('en-us', {year: 'numeric', month: '2-digit', day: '2-digit'}). replace(/(\d+)\/(\d+)\/(\d+)/, '$3-$1-$2'); // => '2016-06-05'