admin管理员组

文章数量:1026989

So lately I've seen a lot of verified bots using the new "Unix Timestamps". But when I try <t:${message.author.createdTimestamp}> it somehow outputs the 50000th year, lol. So that's the problem.

I will really appreciate any form of support because that problem seems controversial to me.

Maybe there is some package or method which can solve this issue. Sadly, I don't know what it is.

So lately I've seen a lot of verified bots using the new "Unix Timestamps". But when I try <t:${message.author.createdTimestamp}> it somehow outputs the 50000th year, lol. So that's the problem.

I will really appreciate any form of support because that problem seems controversial to me.

Maybe there is some package or method which can solve this issue. Sadly, I don't know what it is.

Share Improve this question asked Nov 16, 2021 at 5:56 8less8less 912 gold badges5 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

It looks like <t:###> will accept seconds only and the timestamp is in milliseconds. You'll need to divide the timestamp by 1000 and as it only accepts integers, either round it (using Math.round(), Math.floor(), etc.) or convert it to an integer (using parseInt()).

Any of these should work and display the date correctly:

<t:${Math.round(message.author.createdTimestamp / 1000)}>
<t:${parseInt(message.author.createdTimestamp / 1000, 10)}>

So lately I've seen a lot of verified bots using the new "Unix Timestamps". But when I try <t:${message.author.createdTimestamp}> it somehow outputs the 50000th year, lol. So that's the problem.

I will really appreciate any form of support because that problem seems controversial to me.

Maybe there is some package or method which can solve this issue. Sadly, I don't know what it is.

So lately I've seen a lot of verified bots using the new "Unix Timestamps". But when I try <t:${message.author.createdTimestamp}> it somehow outputs the 50000th year, lol. So that's the problem.

I will really appreciate any form of support because that problem seems controversial to me.

Maybe there is some package or method which can solve this issue. Sadly, I don't know what it is.

Share Improve this question asked Nov 16, 2021 at 5:56 8less8less 912 gold badges5 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

It looks like <t:###> will accept seconds only and the timestamp is in milliseconds. You'll need to divide the timestamp by 1000 and as it only accepts integers, either round it (using Math.round(), Math.floor(), etc.) or convert it to an integer (using parseInt()).

Any of these should work and display the date correctly:

<t:${Math.round(message.author.createdTimestamp / 1000)}>
<t:${parseInt(message.author.createdTimestamp / 1000, 10)}>

本文标签: javascriptDiscordjs How do I convert timestamp to unix oneStack Overflow