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()
If you don't mind including an additional (but small) library, Sugar.js provides lots of nice functionality for working with dates in JavaScript. To format a date, use the format function:
new Date().format("{yyyy}{MM}{dd}")