格式日期与elixir dateTime到RFC2616格式
我想实现一个代码,将DateTime对象转换为〜U [2022-06-07 18:37:16.842920Z]
,例如TUE,2022年6月7日, 37:16 GMT
。我不想使用calendar.datetime.format.httpdate,因为我们的代码库已经使用了DateTime。
我需要它以RFC2616格式发送API标头。任何帮助都将受到赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Elixir 1.11.0引入
/a>这就是您所需要的。请注意,
DateTime
和日历
是有不同目的的内置模块。使用它们的混合应该没有问题。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.