This is where the concept of abstractions really comes into play. Since you're really only dealing with 3 simple functions that you don't want to repeat over and over again in your code, just write one helper function and then use that in your code:
function getFormattedDate() {
return getYear() . getMonth() + 1 . getDate();
}
Then whenever you need the date, run:
var d = getFormattedDate();
or
alert(getFormattedDate());
or
document.getElementById("date").innerHTML = "Today's date is " + getFormattedDate();
To keep your getFormattedDate function out of the global scope, and be sure you don't conflict with another implementation of getFormattedDate, use namespacing:
var myUtils = {
getFormattedDate: function() {
return getYear() . getMonth() + 1 . getDate();
}
};
then invoke it as:
alert( myUtils.getFormattedDate() );