Date conversion from POSIXct to Date in R

The problem here is timezones – you can see you’re in "HKT". Try:

as.Date(as.POSIXct("2013-01-01 07:00", 'GMT'))
[1] "2013-01-01"

From ?as.Date():

[“POSIXct” is] converted to days by ignoring the time after midnight
in the representation of the time in specified timezone, default UTC

Leave a Comment