Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将系统日期和时间输出到文本文件。当我这样做时,时区就会消失。一个例子如下:
> Sys.time() [1] "2012-05-24 09:58:38 CDT" > currentTime <- Sys.time() > currentTime [1] "2012-05-24 09:58:49 CDT" > cat(as.character(currentTime), sep = "\n") 2012-05-24 09:58:49
时区发生了什么以及如何恢复?
试试这个:
cat(format(Sys.time(),usetz = TRUE))
POSIXct 对象的 print 方法调用format,usetz = TRUE这就是您在控制台中看到时区的原因(print 方法在后台调用)。
format
usetz = TRUE