Is there a function in haskell for epoch time in seconds / milliseconds ?
perhaps something similar to java\'s
System.currentTimeMillis();
>
Yes.
getCurrentTime :: IO UTCTime.
UNIX epoch time could be retrieved as Int
like that:
> :m + Data.Time System.Locale Control.Applicative
> epoch_int <- (read <$> formatTime defaultTimeLocale "%s" <$> getCurrentTime) :: IO Int
> epoch_int
1375025861
UPD: as other users noticed, there is much more simple way to do that:
> :m + Data.Time.Clock.POSIX
> round `fmap` getPOSIXTime
1375040716
it :: Integer