+ 1

Hey!! I have come up with a problem in java script date method.

According to this code~ var n=new Date(); var month = n.getMonth(); document.write(month); The output should be 03(for now as it is March) but it is showing 02. Please help me out.

22nd Mar 2018, 2:45 AM
Dev Dutt
Dev Dutt - avatar
2 Respuestas
+ 6
I do believe it starts from 0. (so january is 0, december would be 11) so just add 1 before outputting it
22nd Mar 2018, 2:47 AM
J.G.
J.G. - avatar
+ 2
Thanks..
22nd Mar 2018, 5:28 AM
Dev Dutt
Dev Dutt - avatar