peoj

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

outlog

of a client? or the server? (btw imho your server should always run in utc)

Most Liked

outlog

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..

cmo

cmo

Use Timex’s Timezone.local()?

craig

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

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}'")

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36689 110
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement