benonymus

benonymus

Timex.Timezone.convert/2 question

Hey I am using this function, and the result does only show until the seconds, doesn’t show milliseconds, not even the .000000. Why is that?
Before it did show it.
It used to return this:

2018-09-15T15:00:00.000000+02:00

and now it returns this:

2018-03-10T05:00:00-04:00

I am using timex 3.4

Marked As Solved

benonymus

benonymus

ok so at the end I used Timex.set/2 and setting the microsecond field

Also Liked

NobbZ

NobbZ

Then please use proper formatting instead of relying on debug output that may change without a warning at any point in time.

NobbZ

NobbZ

If you want to format a time for presentation use Timex.format, the inspection output is for debugging only and might change its presentation without any warnings.

OvermindDL1

OvermindDL1

Hmm, as per the documentation I linked I don’t see why this wouldn’t work for you based on the information given?

iex(1)> Timex.format(DateTime.from_unix!(1549385336000000, :microsecond), "%FT%T.%f%z", :strftime)
{:ok, "2019-02-05T16:48:56.000000+0000"}
iex(2)> Timex.format(DateTime.from_unix!(1549385336000001, :microsecond), "%FT%T.%f%z", :strftime)
{:ok, "2019-02-05T16:48:56.000001+0000"}
OvermindDL1

OvermindDL1

Oh! Then my snippet should work perfectly for it as it always prints microseconds, even out to full 0’s if the datetime doesn’t contain them. You really don’t want to change a time to print out for something else, you’d be surprised by the bugs that can happen. ^.^

NobbZ

NobbZ

Can you give a more complete example about how you create the dates and how you convert them?

Where Next?

Popular in Questions Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement