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()
You can use the toISOString function :
toISOString
var today = new Date(); today.toISOString().substring(0, 10);
It will give you a "yyyy-mm-dd" format.