Search
 
SCRIPT & CODE EXAMPLE
 

ELIXIR

elixir string to time

defmodule SomeModule do
  @doc """
      iex> SomeModule.to_date("2020-01-30")
      ~D[2020-01-30]
  """
  def to_date(string), do: Date.from_iso8601!(string)

  @doc """
      iex> SomeModule.to_date_time("1997-07-16T19:20:30.45Z")
      ~U[1997-07-16 19:20:30.45Z]
  """
  def to_date_time(string) do
    case DateTime.from_iso8601(string) do
      {:ok, date_time, _offset} -> date_time
      error -> error
    end
  end
end
Comment

PREVIOUS NEXT
Code Example
Elixir :: elixir try rescue 
Elixir :: elixir try catch 
Elixir :: elixir map 
Elixir :: hello world in elixir 
Elixir :: elixir timex format 
Elixir :: liveview component mount 
Elixir :: elixir anonymous function 
Elixir :: extract changeset error elixir 
Scala :: scala schemaPayload json 
Scala :: scalable meaning 
Scala :: reduce scala 
Scala :: scala schema json spark 
Actionscript :: truncate restart identity - syntax error at or near "identity" 
Excel :: remove space from excel cell 
Excel :: excel or 
Perl :: perl while loop 
Perl :: len perl 
Pascal :: delay() in Pascal 
Powershell :: Take ownership of a folder 
Gdscript :: godot check left mouse button 
Abap :: abap if statement 
Assembly :: jinja loop index 
Assembly :: that long word from mary poppins 
Assembly :: array days of the week 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery remove required attribute 
Javascript :: react refresh page 
Javascript :: javascript void(0) href 
Javascript :: get tomorrows date using moment 
Javascript :: random number between 0 and 3 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =