Why is this count up days command resetting after 30 days

i dont really understand how to make commands, i just combine a bunch of commands to do what i need so idk what is wrong with it
!addcom !beardage /me $(eval a=$(countup Oct 23 2023 US/Eastern);y=a.match(/\d+ year/);d=a.match(/\d+ day/);(y?parseInt(y[0].split( )[0]):0)*365+(d?parseInt(d[0].split( )[0]):0)) days since beard shaved

Hey @inepd!

Contrary to what the documentation says, I found that I have a way more reliable experience when I write the date following the international standard.

But the biggest issue you’ll face while using $(countup) is that you strictly want the number of days, and $(countup) will give you a response in years, months, days, hours, etc. and as you know, months and years don’t have a fixed number of days.

Instead, I can suggest you a different solution which relies on seconds, and since there’s a fixed number of seconds in a day, you’ll avoid being off by a day or two, you could have, however, an offset of a few hours, but that’s better than days.

$(eval today = new Date(); startDate = new Date('2023-10-23T00:00:00.000-05:00'); diff = Math.trunc((today - startDate) / 1000); daysDiff = Math.floor(diff / 86400); `${daysDiff} days since beard shaved`;)

I just had to edit this code:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.