peoj
How can I determine the current timezone of the local system (e.g. Etc/UTC)?
This approach would work for me, but seems like I must be missing a built-in API of some sort!
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Hey, I know this has been discussed ad nauseum, but I couldn’t find a definitive answer or at least some consensus around this, so let me...
New
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #code-sync
- #exunit
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #blog-post
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
outlog
of a client? or the server? (btw imho your server should always run in utc)
peoj
The local system where the elixir app is currently being run, so "server’ I guess.
Agreed but I can’t make that assumption.
outlog
app logic can/should be in a way that the server timezone is irrelevant.. aka always Start with DateTime.utc_now() or similar in the logic and go from there..
anyways, maybe something like
(I’m utc+2 currently)
pretty sure elixir doesn’t expose it.. since it’s a very bad path to venture down of.. time is hard enough as it is..
peoj
Thanks for the help, that works nicely for the offset.
I understand the difficulties inherent in timezones in some applications. For the purposes of my app I still need to know the current timezone and offset of the system.
lud
As a workaround you could call
System.cmd("date", ["+%Z"])or compare the output ofSystem.cmd("date", ["+%H:%M:%S"])withDateTime.utc_now()but that does not seem very reliable.ericgray
Why not just use the function in the Stackoverflow article
If you compare it with
DateTime.utc_now()you would need to get the offset.lud
Well it seems that I read the topic not from the beginning. I completely overlooked the first post, sorry.
That being said,
"+%Z"gives"CEST"on my machine, that is not very useful as it still requires to have a timezone database of some sort. And if you have one, I bet there is a function in the library that would give you your current timezone anyway.ericgray
Right didn’t realize he needed the offset. The only thing that comes to mind is Tzdata database. Elixir School has a nice article on how to use it. The only problem with this approach is you have to pass in the name of the zone, i.e. “America/Chicago”.
If there was some kind of way you could use
System.cmd("date", ["+%Z"]to get the time zone and pass that in I think it would work.billposters
The host OS, and packages available are going to determine what TZ info you can get from the system directly. For example, on Debian you can
cat /etc/timezoneand getEurope/Londonbut it’s not guaranteed that the timezone packages will be installed on the host.If you don’t control the host (and packages installed) then realistically you’re only going to be able to resolve the offset, not the named TZ e.g. “Etc/0” not “Europe/London” because there are more named TZ aliases in an offset, meaning it’s not a 1-1 relationship.
cmo
Use Timex’s
Timezone.local()?