I have seen it, but I can’t use this because I don’t know how to write the cod I needed!!
I need the time like "Mon, 29 Oct 2018 23:38:55 +0330"
for Email headers
for example:
new_email(
to: "#{info.email}",
from: "noreply@name.com",
subject: "#{info.subject}",
headers: %{
"From" => "noreply@name.com",
"Return-Path" => "#{info.email}",
"Subject" => "#{info.subject}",
"Date" => "Mon, #{iran_now_time.day} Oct #{iran_now_time.year} #{iran_now_time.hour}:#{iran_now_time.minute}:#{iran_now_time.second} #{iran_now_time.zone_abbr}",
"message-id" => "<#{:base64.encode(:crypto.strong_rand_bytes(64))}@name.com>"
},
if you use Timex.format/2
? how will you write this code ?
I used this but I had a bad format error, for example I can’t show the name of the week, if I use this:
Timex.format!(iran_now_time, "{WD}, {M} {YYYY} {M} {Z}")
** (Timex.Format.FormatError) invalid format: {:format, "Expected at least one parser to succeed at line 1, column 0."}
(timex) lib/format/datetime/formatter.ex:54: Timex.Format.DateTime.Formatter.lformat!/4
it is not important that I should use Timex, I just want to create that time.
I edited my code:
Timex.format!(iran_now_time, "Mon, {D} Oct {YYYY} {h24}:{0m}:{0s} {Z}")
I have that problem yet
Update:
Thank you , it was fixed.
Timex.format!(iran_now_time, "{WDshort}, {D} {Mshort} {YYYY} {h24}:{0m}:{0s} {Z}")
I made mistake to write [
after h24
, I have a question , how can I learn Time short code like you wrote?
E,g: {Mshort}
or {WDshort}
, Are there the resources?
final code: Timex.format!(iran_now_time, "{WDshort}, {D} {Mshort} {YYYY} {h24}:{0m}:{0s} {Z}")