What is the Haskell equivalent of this shell command?
$ date "+%s%3N"
1489694389603
Datetime Unix timestamp contains milliseconds.
Timestamps in milliseconds and other units. Timezones, Unix timestamps in milliseconds & UTC.
You can use getCurrentTime from Data. Time. Clock . Save this answer.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With