4

I have a date and time value which I'm using POSIXct to store in a variable. and when I use as.Date the date is different - why ?

x<-as.POSIXct("2012-02-25 19:00:00")
as.Date(x)
 [1] "2012-02-**26**"

Why is it incrementing day by 1?

Sri
  • 1,130
  • 1
  • 15
  • 31

1 Answers1

4

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.

However when you use as.Date without declaring a time zone it will default to GMT. GMT is 5 hours ahead of EST so 25/02/2012 19:00 is 00:00 26/02/2012.

amwill04
  • 1,330
  • 1
  • 11
  • 18