Command to get amount of days since date

Asked Oct 31, 2023·1 reply·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hello all and happy Halloween, on my stream we have a running joke that it's the same persons birthday every single day. I'd like to create some sort of command in which when it's triggered it wishes said person a happy 228th birthday (if it were executed today) a happy 230th birthday if it were executed in 2 days from now ecr.

Thanks in advance

1 reply

Hey @Cheerful Skunk!

Since you haven't given a start date, I've guessed it from the time of your post and the amount of days it's been since, I came up with 2023-03-17 (yyyy-mm-dd), feel free to update the date in the code if necessary, but make sure to follow the yyyy-mm-dd format.

$(eval today = new Date(); startDate = new Date('2023-03-17'); diff = Math.trunc((today - startDate) / 1000); daysDiff = Math.floor(diff / 86400); `Happy ${daysDiff}th birthday, USERNAME!`;)

Don't forget to edit the USERNAME field.

⚠️ There might be a slight offset of a couple hours since the command works in the UTC timezone.