Greetings - 

 

I'm battling POSIXct, as per the code below.  My input is actually an XL
file, but the weird results below correctly model what I am seeing in my
program.

 

Before I punt and use lubridate or timeDate, could anyone please help me
understand why POSIXct forces my variable back to GMT?

 

I suspect that I'm not properly coding the tzone value, but it does not
throw an error as-is.

 

 

> tstamp <- "2011-05-22 11:45:00 MDT"

> mode(tstamp)

[1] "character"

> 

> dateP <- as.POSIXct(tstamp, origin="1970-01-01", tzone="MDT")

> mode(dateP)

[1] "numeric"

> dateP

[1] "2011-05-22 11:45:00 MDT"

> 

> dateN <- as.numeric(dateP)

> dateN

[1] 1306086300

> 

> dateP2 <- as.POSIXct(dateN, origin="1970-01-01", tzone="MDT")

> dateP2

[1] "2011-05-22 18:45:00 MDT"

 

Many thanks.

 

Galen Moore


	[[alternative HTML version deleted]]

