var thedate = new Date;

var themonth = thedate.getMonth() + 1;
var theday = thedate.getDate();

var theyear = thedate.getFullYear()

if (theyear < 1000){
theyear = theyear + 1000
}