I want to implement a piece of code that converts a datetime object like ~U[2022-06-07 18:37:16.842920Z]
to a format like Tue, 7 Jun 2022 18:37:16 GMT
. I do not want to use the Calendar.DateTime.Format.httpdate since our codebase already uses DateTime.
I need it to send in API headers with RFC2616 format. Any help is appreciated.
Elixir 1.11.0 introduced
Calendar.strftime/3
that is what you need. Please note thatDateTime
andCalendar
are different built-in modules that serve different purposes. There should be no problem in using them combined.