类POSIXct有两个datetime对象,如下所示:
> x = as.POSIXct('2013-03-31 01:39:42')
> y = as.POSIXct('2013-03-31 03:11:24')
两个日期时间的时间差计算为31.7分钟(或1902秒)。
> y - x
Time difference of 31.7 mins
但是,这种情况下的时间差是91.7分钟(或5502秒)。有人能给我解释一下这个错误吗?
发布于 2014-11-04 18:37:56
你听说过夏令时吗?
x
#[1] "2013-03-31 01:39:42 CET"
y
#[1] "2013-03-31 03:11:24 CEST"
看看时区。
与此相比较:
x = as.POSIXct('2013-03-31 01:39:42', tz="GMT")
y = as.POSIXct('2013-03-31 03:11:24', tz="GMT")
y-x
#Time difference of 1.528333 hours
https://stackoverflow.com/questions/26742377
复制相似问题