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()
I didn't like adding to the prototype. An alternative would be:
var rightNow = new Date(); var res = rightNow.toISOString().slice(0,10).replace(/-/g,""); document.body.innerHTML += res;