What am I doing wrong?
This gives med 4 numbers
d = new Date();
dag = d.getDate();
manad = d.getMonth();
manad++;
ar = d.getFullYear();
alert(ar+manad+dag);
This gives me 8 numbers: the only difference is the ”+ in the alert message
d = new Date();
dag = d.getDate();
manad = d.getMonth();
manad++;
ar = d.getFullYear();
alert('' + ar+manad+dag);
In your first example it’s doing a javascript add of the numbers together. In the second example it’s doing a concatenation because it thinks it’s a string.
The output of the first example would be the day – 13, month – 11 then add 1, year = 2011 so it would be 13 +12 + 2011 = 2036
The second example would be 20111213, year – month + 1, day