Ramblings from a Researcher-In-Training

Peer Reviewed

A Shortcut for Generating Local Timestamps in Discord

I spend a lot of time in Discord — at this point, it is probably my most-used social media app. Part of this is certainly due to the fact that I help moderate the Relay FM Members Discord; a delightful and international gathering of like-minded nerds. Because of this diverse and widespread community (and the occasional live-streamed event therein), handling timezone conversion is a frequent occurrence; like sharing a keyboard group buy date or marking the next live podcast stream on your calendar. Luckily, Discord recently added Unix timestamp message formatting, which allows you to send a string that automatically displays the appropriate client-side time. So, instead of saying "Hey, the game is on August 20th at 12PM CDT" and everyone translating on their end, I can instead say "Hey, the game is on <t:1629478800>" and Discord natively parses that Unix timecode (wrapped appropriately) into the end-user's local time. It looks something like this:

A screenshot of a Discord conversation demonstrating the timestamp feature.
Using the Unix timecode for a date/time automatically displays the end-user’s local time — so Zach sees 1PM EDT!

But of course, who can convert human-readable time to Unix time (seconds since midnight UTC on January 1st, 1970) on the fly? I know I can't — but Siri Shortcuts sure can!


Is this article helpful? Consider saying thanks by buying me a coffee!
Buy me a coffeeBuy me a coffee

Generating Unix Time in Shortcuts

This sort of thing is exactly what Shortcuts is great at — taking otherwise-tedious but ostensibly-handy tasks and mostly removing the tedium. In this case, I made a Shortcut that can quickly generate the Unix timecode Discord needs to do its client-local-time magic. I started simple: I wanted a Shortcut to take the Current Date/Time, convert that to the Unix timecode, placing it in its home within the <t:[timecode]> format, and copying it to my clipboard. That only took three Shortcuts actions:

Screenshot of a simple Siri Shortcut to generate the Discord timecodes.
Starting simple is usually where I begin when making a new Shortcut — the fewest actions possible to get the result I’m looking for.

But of course, once the most basic form of a Shortcut was there, I got to thinking about improvements and edge cases. For starters, I also wanted to be able to pick something other than the current date and time — pretty straightforward change, I just swapped in a Choose Date action, which covers both Current Date and arbitrary dates quite nicely. Then I added in the ability to scan your clipboard for text containing a date — in the case where I might want to copy a message out of Discord and quickly convert the date in said message. Apple handily provides a Get Dates From Input action, which is usually smart enough to pick out dates and times from fairly lengthy strings of text (I think it’s the same system that detects dates in iMessages). A little bit of error handling, and some extra actions to automatically reopen Discord and give some helpful notification feedback, and the final shortcut for this simple Discord trick is ready!

Four screenshots of Shortcuts actions for the Discord Timestamp Generator shortcut.
A simple three-step shortcut can quickly turn into 37 actions, error handling, and decision trees!

Now, when I’m sharing an event in Discord (or reading about one), I can quickly convert the date & time of that event into a more useful format for everyone in the server with just a quick tap of a button.

Shortcuts And Systems: Start Simple, Then Sprawl

I wanted to write about this Siri Shortcut for an obscure Discord feature not so much because I think tons of people will find it useful, but more because it illustrates well how I typically end up using Shortcuts: I have a small “mosquito task” type of problem that I can solve in a few Shortcuts actions…but then I really solve it by taking the time to fully flesh-out the Shortcut. I start small, and then build out the tool to be more all-encompassing and hopefully anticipate the needs and problems of Future-Me. I find that I follow similar patterns in a lot of areas where I’m problem solving: find the “last step” of the solution, so to speak, and then build out a system around that “last step” to anticipate unforeseen circumstances. I think this sort of thinking can be helpful for people trying to create systems for themselves but don’t end up using them — sometimes, you need to take the time to make your system as appealing as possible for Future-You to actually get them to use the system you’ve built them.