[英]Facilities to work with datetime format in R: %Y-%m-%d %H:%M:%OS-0200
I have a datetime string in a format of 27.04.2020 15:50:30.391-0700
.我有一个格式为27.04.2020 15:50:30.391-0700
的日期时间字符串。 0700
after dash was to denote the timezone relative to GMT.破折号后的0700
表示相对于 GMT 的时区。
I found it kind of annoying in R
as there is no known tools to work with this type of non-standard datetime format.我发现R
有点烦人,因为没有已知的工具可以处理这种类型的非标准日期时间格式。 I use R way more than python on a daily basis, yet pandas
is just very intuitive to use for this and pandas
can actually do time diff directly on these format when they are proper python datetime
objects. I use R way more than python on a daily basis, yet pandas
is just very intuitive to use for this and pandas
can actually do time diff directly on these format when they are proper python datetime
objects. R, as of this minute I could not figure out a way to do it; R,到目前为止,我还想不出办法; I've experimented quite a bit of string replacing, as.character and more (to no avail).我已经尝试了很多字符串替换,as.character 等等(无济于事)。
Can anyone prove me wrong?谁能证明我错了?
You need to change display options to see the milliseconds.您需要更改显示选项以查看毫秒数。 Try this one:试试这个:
library(lubridate)
time_string <- '27.04.2020 15:50:30.391-0700'
time_lubridate <- dmy_hms(time_string)
options(digits.secs=3)
time_lubridate
> time_lubridate
[1] "2020-04-27 22:50:30.391 UTC"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.