How to format timestamp display in Discord bot embed messages

I’m working on a moderation bot for my Discord server and need help with date formatting. When someone gets banned from the server, my bot sends a log message to our staff channel. Everything works fine except the timestamp looks really messy and hard to read.

const logEmbed = new discord.MessageEmbed()
    .setTitle("Member Banned")
    .setDescription(`**${bannedUser}** has been removed from the server.`)
    .setColor("#ff6b35")
    .addField("Action Time", message.createdAt, true)
    .addField("Moderator", `<@${message.author.id}>`, true)
    .addField("Ban Reason", banReason, false);

bot.channels.cache.get("123456789012345678").send({embeds: [logEmbed]});

The problem is that the timestamp shows up as a long confusing string with lots of extra info. I want it to display as DD/MM/YYYY HH:MM AM/PM format using Australian Eastern Time. What’s the best way to convert the timestamp into this cleaner format before adding it to the embed field?

Use toLocaleString() with the right locale and timezone options. For Australian Eastern Time in DD/MM/YYYY format:

const formattedTime = message.createdAt.toLocaleString('en-AU', {
    timeZone: 'Australia/Sydney',
    day: '2-digit',
    month: '2-digit', 
    year: 'numeric',
    hour: 'numeric',
    minute: '2-digit',
    hour12: true
});

Then swap your addField line with .addField("Action Time", formattedTime, true). Australia/Sydney automatically handles daylight saving between AEDT and AEST - no extra logic needed. The en-AU locale gives you DD/MM/YYYY instead of the American MM/DD/YYYY format.

Discord has native timestamp formatting that’s way cleaner than handling dates manually. Just use <t:UNIX_TIMESTAMP:F> - it automatically adjusts to each user’s timezone and preferences.

const unixTimestamp = Math.floor(message.createdAt.getTime() / 1000);
const discordTimestamp = `<t:${unixTimestamp}:F>`;

Then use discordTimestamp in your addField. The :F flag gives you full date and time. Want something shorter? Try :f for compact datetime or :R for relative time like “2 hours ago”. Australian users see AEST/AEDT automatically while American staff see their local time - way more user-friendly than forcing everyone into one timezone.

moment.js works great if you’re already using it - moment(message.createdAt).tz('Australia/Sydney').format('DD/MM/YYYY hh:mm A') does exactly what you want. But honestly, the Discord timestamp formatting benmoore mentioned is way better since users automatically get their own timezone.