Reputation: 30756
What is the Haskell equivalent of this shell command?
$ date "+%s%3N"
1489694389603
Upvotes: 11
Views: 4060
Reputation: 30756
Using the time package:
Use getPOSIXTime
, which returns a NominalDiffTime
. This represents a fractional number of seconds, with a precision of 10-12 seconds.
Multiply 1000 to convert from seconds to milliseconds.
NominalDiffTime
implements the RealFrac
class, so you can use round
to convert to an integer.
import Data.Time.Clock.POSIX (getPOSIXTime)
λ> (round . (* 1000)) <$> getPOSIXTime
1489694668011
Upvotes: 21