For logging purposes, how can an R script get the current date and time, in the UTC time zone, as an ISO 8601 string in this format:
2015-12-31T14:26:56.600374+00:00
as.POSIXlt
seems to be the solution, and the documentation claims that it accepts a format parameter, but I can't make that work (on R version 3.1.3):
> as.POSIXlt(Sys.time(), "UTC", "%Y-%m-%dT%H:%M:%S")
[1] "2015-04-08 14:37:58 UTC"
> as.POSIXlt(Sys.time(), tz="UTC", format="%Y-%m-%dT%H:%M:%S")
[1] "2015-04-08 14:38:02 UTC"
> as.POSIXct(Sys.time(), tz="UTC", format="%Y-%m-%dT%H:%M:%S")
[1] "2015-04-08 11:38:22 BRT"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…