[英]R POSIXct and as.Date
I have a date and time value which I'm using POSIXct to store in a variable. 我有一个日期和时间值,我正在使用POSIXct存储在变量中。 and when I use as.Date the date is different - why ?
当我使用as.Date时,日期不同 - 为什么?
x<-as.POSIXct("2012-02-25 19:00:00")
as.Date(x)
[1] "2012-02-**26**"
Why is it incrementing day by 1? 为什么每天递增1?
By simply using x<-as.POSIXct("2012-02-25 19:00:00")
you will be setting the time zone, tz
, to your current systems time zone, EST. 只需使用
x<-as.POSIXct("2012-02-25 19:00:00")
您就可以将时区tz
设置为当前系统时区EST。
However when you use as.Date
without declaring a time zone it will default to GMT. 但是,如果在未声明时区的情况下使用
as.Date
,则默认为GMT。 GMT is 5 hours ahead of EST so 25/02/2012 19:00 is 00:00 26/02/2012. 格林威治标准时间比美国东部时间早5小时,因此25/02/2012 19:00是00:00 26/02/2012。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.