Hi,
What transformation is needed to get date input from an HTML date tag in a form to be cast correctly to a :utc_datetime
type in a schema?
I have a schema for a calendar event:
schema "events" do
field :start_date, :utc_datetime
field :end_date, :utc_datetime
timestamps()
end
And in my form.html.eex:
<input type="datetime-local">
I came across timex
but I do not know where this fits in the changeset, or if this is correct approach. Any guidance most welcomed.
def changeset(event, attrs) do
event
|> cast(attrs, [:start_date, :end_date])
end
Also, does it matter than I am using :timestampz in my Postgres migration?
create table(:events) do
add :start_date, :timestamptz
add :end_date, :timestamptz
end
Thanks!