Example: R Time and Date

ISO 8601 Format

Reading time:

as.POSIXlt(Sys.time(), "UTC", "%Y-%m-%dT%H:%M:%S")
## [1] "2018-03-20 07:13:30 UTC"
as.POSIXlt(Sys.time(), "Asia/Baghdad", "%Y-%m-%dT%H:%M:%S")
## [1] "2018-03-20 10:13:30 +03"

Writing time:

tm = as.POSIXlt(Sys.time(), "Asia/Baghdad", "%Y-%m-%dT%H:%M:%S")
strftime(tm , "%Y-%m-%dT%H:%M:%S%z")
## [1] "2018-03-20T10:13:30+0300"
strftime(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")
## [1] "2018-03-20T10:13:30+0300"

 Tech    19 Dec, 2017

Any work (images, writings, presentations, ideas or whatever) which I own is always provided under
Creative Commons License Creative Commons Attribution-Share Alike 3.0 License

Mert Nuhoglu is a Trabzon-born programmer and data scientist.

You may also like...