Search code examples
elixirphoenix-frameworkecto

How to insert string to DATE column and TIME column from Ecto


I would like to insert string '2020-04-16' to DATE type column, and string type '12:00' to TIME type column from Ecto. DB is MySQL.

Please give me advice.


Solution

  • I don't know if it correct way or not.

        {:ok, game_date} = Date.from_iso8601("2020-04-16")
        {:ok, game_time} = Time.from_iso8601("12:00:00")
    
    

    It worked.