Shortcode to convert timestamp to any time zone

Hi folks, I was recently trying to convert bare timestamps into different time zones in Hugo, and could not find any built-in function to do this consistently. So, I wrote a shortcode for this purpose, that I would like to share with you.

The problem I was trying to solve is as follows.

I was trying to keep a diary section in my Hugo site. I use keyboard shortcuts to create timestamps to keep the time when I enter a new passage, which I then want to convert into more readable formats while keeping the original timestamp. I would pretty much want the ending results (e.g. 7pm) to stay exactly as it is, for all future builds, regardless of summer/winter clock changes or potential location changes.

So, the verbosely documented shortcode and its required site configs are here: Time zone conversion shortcode for Hugo

I need to call it very frequently in my site, so I made the deliberate decision to use only positional arguments. You may change it however you want, should you wish to use it for your own project.

Let me know if you have any suggestions. Cheers!

2 Likes