What is wrong with my code?
var myDate = new Date();
var myString = "" +
( (typeof myDate !== "undefined") && ((myDate.getUTCMonth() + 1) < 10) ? "0" : "" ) +
( typeof myDate !== "undefined" ? (myDate.getUTCMonth() + 1) + myDate.getUTCDate() + myDate.getUTCFullYear().toString().substr(2,2): "" );
return myString;
Why is my code returning 5 digits string such as "03116"? Is it because dates are assigned by reference?
EDIT: Thanks for the link. But it would really be helpful if someone had a clue about why am I getting a 5 digits string instead of MMDDYY. A have a lot lines based on this code and it would be painful to rewrite it without the concatenation.
EDIT2: Still would like to know what's wrong in the code? Is it because of assignation by reference?