Why does a date frame returning date with a time zone sometimes?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Why does a date frame returning date with a time zone sometimes?

jcrosbie
This post has NOT been accepted by the mailing list yet.

I have a date from which returns
head(mt, 3)
                DateW             |         Date                               |tempDeg
2 2009-01-01 01:00:00       |         2009-01-01 01:00:00        |          -23.6
3 2009-01-01 02:00:00       |         2009-01-01 02:00:00        |          -25.7
4 2009-01-01 03:00:00       |         2009-01-01 03:00:00        |          -26.5


Why does this return  a time with MST?

mt[1,2]
[1] "2009-01-01 01:00:00 MST"
Reply | Threaded
Open this post in threaded view
|

Re: Why does a date frame returning date with a time zone sometimes?

arun kirshna
I may have misunderstood your question. 

vec1 <- seq(as.POSIXct("2009-01-01 00:00:00",format="%Y-%m-%d %H:%M:%S"),by= '12 hour', length=12)

vec1[1:3] #returns with time zone
#[1] "2009-01-01 00:00:00 EST" "2009-01-01 12:00:00 EST"
#[3] "2009-01-02 00:00:00 EST"

If you don't want the time zone info:,
strftime(vec1,usetz=FALSE)[1:2]
#[1] "2009-01-01 00:00:00" "2009-01-01 12:00:00"


Also, you can change the time zone,



Sys.setenv(TZ="GMT")
 vec1[1:2]
#[1] "2009-01-01 05:00:00 GMT" "2009-01-01 17:00:00 GMT"

It is not clear what you want.
A.K.


I have a date from which returns
head(mt, 3)
                DateW             |         Date                               |tempDeg
2 2009-01-01 01:00:00       |         2009-01-01 01:00:00        |          -23.6
3 2009-01-01 02:00:00       |         2009-01-01 02:00:00        |          -25.7
4 2009-01-01 03:00:00       |         2009-01-01 03:00:00        |          -26.5


Why does this return  a time with MST?

mt[1,2]
[1] "2009-01-01 01:00:00 MST"

______________________________________________
[hidden email] 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.