This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
A reliable way to format dates with Elm
version 2.1.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.1.2
Committed At 2018-10-02 22:09:52 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1



A reliable way to format dates with Elm.

Build Status

Using the elm package

elm package install ryannhg/elm-date-format

What is elm-date-format?

If you're coming from Javascript, you might have heard of MomentJS.

MomentJS is a great library for formatting dates!

elm-date-format has the same formatting options as Moment, but uses Elm's awesome type system to provide human readable names, and catch typos for you at compile time!

No need to remember the difference between mm and MM and M!

A quick example

import Date exposing (Date)
import DateFormat

-- Create a custom formatter

yourFormatter : Date -> String
yourFormatter =
        [ DateFormat.monthNameFull
        , DateFormat.text " "
        , DateFormat.dayOfMonthSuffix
        , DateFormat.text ", "
        , DateFormat.yearNumber

-- Using your formatter, format your date as a string!

yourPrettyDate : String
yourPrettyDate =
    case Date.fromString "2018-02-05T00:00:00.000" of
        Ok date ->
            yourFormatter date

        Err ->
            "This shouldn't happen..."

Would make yourPrettyDate return:

"February 5th, 2018" : String