Working with time: Difference between revisions

From ElixirBlocks
Jump to: navigation, search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:


https://www.youtube.com/watch?v=UVvPXbtUJAg
https://www.youtube.com/watch?v=UVvPXbtUJAg
==Additional==
https://stackoverflow.com/questions/62443581/what-is-the-correct-way-of-shifting-the-timezone-elixir
https://stackoverflow.com/questions/76377060/how-to-convert-updated-at-to-conventional-12-hour-format-with-my-time-zone?noredirect=1#comment134681629_76377060

Latest revision as of 12:22, 1 June 2023

Best article on working with time

https://elixirschool.com/en/lessons/basics/date_time

Quick reference

Get time:

DateTime.utc_now()


To convert time into human readable form:

d = DateTime.utc_now()
Calendar.strftime(d, "%y-%m-%d %I:%M:%S %p")


Timezone data

Elixir does not have built in support for timezone data. You need to use this module:

https://github.com/lau/tzdata

A useful video on setup and use:

https://www.youtube.com/watch?v=UVvPXbtUJAg

Additional

https://stackoverflow.com/questions/62443581/what-is-the-correct-way-of-shifting-the-timezone-elixir

https://stackoverflow.com/questions/76377060/how-to-convert-updated-at-to-conventional-12-hour-format-with-my-time-zone?noredirect=1#comment134681629_76377060