我有个约会。我如何通过“时代”对其进行格式化,使其成为格式:
Wed, 02 Oct 2002 15:00:00 +0200或
Wed, 02 Oct 2002 15:00:00 GMT或
Wed, 02 Oct 2002 15:00:00 EST我试过这个:
Timex.format!(my_date, "%D, %d %M %Y %H:%i:%s T", :strftime))但它带来了一个例外:
%Timex.Format.FormatError{message: {:format, "Expected end of input at line 1, column 16"}} (expected a string)当它被转换成其他的、简单的、没有错误的格式时。
发布于 2017-03-11 12:06:01
我相信你在寻找RFC1123 DateTime格式:
iex(1)> Timex.now |> Timex.format!("{RFC1123}")
"Sat, 11 Mar 2017 12:04:21 +0000"
iex(2)> Timex.now |> Timex.to_datetime("America/Chicago") |> Timex.format!("{RFC1123}")
"Sat, 11 Mar 2017 06:04:50 -0600"发布于 2019-05-23 03:11:42
Timex.now()|> Timex.format!("%Y-%m-%d %H:%M", :strftime)产出: 2019-05-23 11:06
https://stackoverflow.com/questions/42734873
复制相似问题