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()
dateformat is a very used package.
How to use:
Download and install dateformat from NPM. Require it in your module:
dateformat
const dateFormat = require('dateformat');
and then just format your stuff:
const myYYYYmmddDate = dateformat(new Date(), 'yyyy-mm-dd');