Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Discord.js specific timestep for code block

enter image description here

How can I make such a time format?

Sample code I made.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.setDescription(`📆 Your account was opened on ${moment(member.user.createdAt).startOf('day').fromNow()}.`)

I want to learn how to show the date of account establishment and server joining as in the image.

>Solution :

Discord will convert any text in the format of <t:SECONDS> into a timestamp. Just replace SECONDS with the seconds since 12:00 am on January 1st, 1970 UTC (also known as the UNIX Epoch). Try this code:

.setDescription(`📆 Your account was opened on <t:${moment(member.user.createdAt).unix()}>.`)

Note that the .unix() method in moment.js will return the seconds since the UNIX Epoch.

You can also check out this website and play around with it to get the other formats, but in every format, the number you need is always the seconds since UNIX Epoch.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading