function convertValue(value) { return String(value < 10 ? '0' + value : value); }; var date = new Date; date = date.getFullYear().toString() + convertValue(date.getMonth()) + convertValue(date.getDate()); alert(date);