I\'m trying to convert a timestamp (ex: \"1493287973015\") from a JSON to a Date type.
So far I created this custom decoder:
stringToDate : Decoder Strin
Two things, a JSON may actually have the milliseconds as an integer, not a string and things have changed since v 0.19 of Elm.
Given that your JSON looks something like.
{
...
"someTime": 1552483995395,
...
}
Then this would decode to a Time.Posix:
import Json.Decode as Decode
decodeTime : Decode.Decoder Time.Posix
decodeTime =
Decode.int
|> Decode.andThen
(\ms ->
Decode.succeed <| Time.millisToPosix ms
)