can anyone tell me why R give such outcome below:
> as.POSIXct("2013-01-01 08:00")
[1] "2013-01-01 08:00:00 HKT"
> as.Date(as.POSIXct("2013-01-01 08:00"))
[1] "2013-01-01"
> as.POSIXct("2013-01-01 07:00")
[1] "2013-01-01 07:00:00 HKT"
> as.Date(as.POSIXct("2013-01-01 07:00"))
[1] "2012-12-31"
Shouldn't it be 2013-01-01
after converting POSIXct
to Date
for 2013-01-01 07:00
, is there any way to change the cutoff from 08:00
to 00:00
?
Update #1
I found the following can fix my problem, but in a less neat way
> as.Date(as.character(as.POSIXct("2013-01-01 07:00")))
[1] "2013-01-01"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…