Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 617 Bytes

unix_timestamp_to_date_time_app.livemd

File metadata and controls

25 lines (19 loc) · 617 Bytes

Convert Unix Timestamp to Date Time

Mix.install([:kino])

Untitled

input = Kino.Input.number("unix_timestamp", default: DateTime.utc_now() |> DateTime.to_unix())
form = Kino.Control.form([unix_timestamp: input], report_changes: true)
frame = Kino.Frame.new()
Kino.listen(form, fn %{data: %{unix_timestamp: v}, origin: origin} ->
  content = Kino.Text.new(DateTime.from_unix!(v) |> DateTime.to_string())
  Kino.Frame.render(frame, content, to: origin)
end)