I want to produce the local time and date in string form, such as, for example:
"2009-09-28-00-44-36.896200000000"
3 Answers 3
Unless I'm missing what your really after, what you want is:
import Data.Time
getCurrentTime
when run in GHCi, you get:
2009年09月28日 01:18:27.229165 UTC
or, for local time (as you indicated and I just caught):
getZonedTime
to get:
2009年09月27日 20:22:06.715505 CDT
Comments
While getCurrentTime and getZonedTime do return the current time and local time respectively, these may not be what liszt is expecting. He wants a string that represents the present time, while both getCurrentTime and getZonedTime returns IO UTCTime and IO ZonedTime respectively
This could do what liszt is looking for:
import Data.Time
currentTime = fmap show getCurrentTime
zonedTime = fmap show getZonedTime
Cheers
Comments
import System.Time
main = do ct <- getClockTime
print ct
or
import Data.Time
main = do zt <- getZonedTime
print zt
1 Comment
main = print =<< getClockTime?