Since decent formatting methods for free date formats are missing in JS, we have to do it manually:
var newdate = new Date();
var datestring = newdate.getFullYear().toString() + ('00' + (newdate.getMonth() + 1)).slice(-2) + ('00' + newdate.getDate()).slice(-2);
“datestring” now contains the date in format “YYYYMMDD”, for example “20160715”.