r - Convert to GMT time without changing date -
i query data base , vector of dates in est time
d =as.posixct(c("2015-06-19 00:38:08 est","2015-06-19 00:38:33 est")) d
here vector
d [1] "2015-06-19 00:38:08 est" "2015-06-19 00:38:33 est"
but want timezone in gmt time.
how can results
d [1] "2015-06-19 00:38:08 gmt" "2015-06-19 00:38:33 gmt"
first, need have unambiguous way of making time in new york time (for est" ambiguous owing existence of eastern time zone in australia well. better est5edt or "america/new_york".) if run code used in different time zone don't same time:
> d =as.posixct(c("2015-06-19 00:38:08 est","2015-06-19 00:38:33 est")) > d [1] "2015-06-19 00:38:08 pdt" "2015-06-19 00:38:33 pdt"
the time zone portion of character times ignored @ time of creation as.posixct. instead use:
> d =as.posixct(c("2015-06-19 00:38:08 est","2015-06-19 00:38:33 est"), tz="america/new_york", usetz=true) > d [1] "2015-06-19 00:38:08 edt" "2015-06-19 00:38:33 edt"
notice correct display of daylight savings time has been displayed. can use format.posixt
output of "the same time" in gmt/uct/utc timezone:
> format(d, tz="gmt") [1] "2015-06-19 04:38:08" "2015-06-19 04:38:33"
i hope fair summary of how strptime
handles datetime input:
date-times implicitly entered in current timezone set locale setting trailing
tz
indicator ignored no warning , stored uct offset determined locale's difference uct. timezone formatting %-'specials' used on outputstrftime
,format.posixt
.
Comments
Post a Comment