peoj
Determining the current system timezone
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!
First Post!
outlog
Most Liked
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
iex(20)> :calendar.time_difference(:calendar.universal_time, :calendar.local_time )
{0, {2, 0, 0}}
(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..
craig
reading timex’s source on how it looks up local time was really informative, they have a lot of sane fallbacks and os-specific lookup methods
Last Post!
DarckBlezzer
I know this post is old but what about this?
I only test this on Ubuntu…
System.shell("timedatectl | grep 'Time zone' | awk '{print $3}'")
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









