Search code examples
ghcjs

How to get the current time with GHCJS?


How to get the current time with GHCJS? Should i try to access Date or use Haskell base libraries? Is there an utility function somewhere in the GHCJS base libraries?


Solution

  • The Data.Time.Clock module seems to work well:

    import Data.Time.Clock (getCurrentTime)
    import Data.Time.Format -- Show instance
    main = do
      now <- getCurrentTime
      print now