I'm a total newbie and I'm confused about this tutorial. I know (at least I think I know) that the functions getDate and get Month and getFullYear are pre-set functions determined by JavaScript.
Why are those preset functions necessary for this tutorial if a new Date (2000,0,1) is being submitted as an argument to formatDate? Does getDate clash somehow with the numbers submitted as an argument?
In function pad, I understand that "number" checks to see whether a number is less than 10 and, if so, adds a zero, but what is the argument submitted to function pad? How does it get the numbers to check?
Can you please take me through (using plain language) this tutorial step by step...thank you in advance
function formatDate(date) {
function pad(number) {
if (number < 10)
return "0" + number;
else
return number;
}
return pad(date.getDate()) + "/" + pad(date.getMonth() + 1) +
"/" + date.getFullYear();
}
print(formatDate(new Date(2000, 0, 1)));