[R] Time OffSet From GMT - Losing it

David Winsemius
2010-10-08T20:08:33Z

On Oct 8, 2010, at 3:43 PM, rivercode wrote:

>
> Losing time offset from GMT:
>
>> sTime = as.POSIXct(paste("2008-03-03","09:30:01"),
>> origin="1970-01-01")
>> sTime
> [1] "2008-03-03 09:30:01 EST"  <---- 9.31am EST
>
>> sTime
> [1] 1204554601
>
>> t = as.numeric(sTime)
>
>
>> as.POSIXct(t, origin="1970-01-01")
> [1] "2008-03-03 14:30:01 EST"  <----- no tz option and t is
sTime +
> 5 hours
> ahead (assume because  I am in EST)
>
>> as.numeric(as.POSIXct(t, origin="1970-01-01"))
> [1] 1204572601  <-----  value of t is sTime +5 hours
>
>> as.POSIXct(t, origin="1970-01-01", tz="GMT")
> [1] "2008-03-03 14:30:01 GMT"   <--- time has not changed even
> though I used
> tz=?GMT?
>
>> as.numeric(as.POSIXct(t, origin="1970-01-01",
tz="GMT"))
> [1] 1204554601 <----- value is still sTime +5 hours though I am
> using GMT

No, ...  it's not.

 > 1204572601-1204554601 == 60*60*5
[1] TRUE   ----> 5 hours difference and also == sTime

>
> I am in New York so am on EST time.
>
> Missing the obvious...but what is it ?
>
> Thanks,
> Chris
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Time-OffSet-From-GMT-Losing-it-tp2968940p2968940.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT