I’m running a Discord bot and the timestamp on some commands returns the wrong month.
with the code
var day = d.getDate();
var y = d.getFullYear();
var month = d.getMonth();
dmy = day + "/" + month + "/" + y // DD/MM/YY
console.log(dmy)
it logs 1/3/2020
today is April 1st, 1/4/2020
I’m running on node 12
I’m not sure what could be wrong, any ideas?
thank you in advance
wh0
2
they start counting from zero, and January is month 0 \:
duh, shouldve looked into it more
thx
here is a simple fix :
var month = d.getMonth() + 1;
thats what I did and it’s working fine now
1 Like
Oh my God, I never noticed that and that means that my database is ruined!
2 Likes
OOOF!
Yea, easy to mess up when it comes to the date module.
angelo
8
Looks like this has been resolved, that’s great! I’m moving the topic to the coding help category just to keep things organized.