How do I convert from unixtime to a date/time in Haskell?

So, the setup is that I have the time, in seconds, since the epoch and I want to turn this into a date I can actually understand. How do I do this in Haskell? If it is possible, how would I extract days/hours/minutes out of this new encoding?


  • Data.Time.Clock.POSIX has posixSecondsToUTCTime (you can convert another numeric type to the input expected POSIXTime with realToFrac).

    Data.Time.Calendar has a lot of the things you need to extract day, month, etc from the Day that forms a part of UTCTime, the rest of the package has other useful utilities.


    Prelude> import Data.Time.Format.ISO8601
    Prelude Data.Time.Format.ISO8601> import Data.Time.Clock.POSIX 
    Prelude Data.Time.Format.ISO8601 Data.Time.Clock.POSIX> iso8601Show $ posixSecondsToUTCTime $ 100