I create a data set with dates starting from 2010-01-01 to 2010-08-1, with 5-minute intervals.
library(chron)
t1 <- chron("2010/01/01","00:00:00",format=c("y/m/d","h:m:s"))
t2 <- chron("2018/01/01","00:00:01",format=c("y/m/d","h:m:s"))
deltat <- times("00:05:00")
date <- seq(t1,t2,by=times("00:05:00"))
I format the date to follow the ISO 8601 standards using the parsedate
package.
library(parsedate)
date1 <- format_iso_8601(date)
head(date1)
[1] "2010-01-01T00:00:00+00:00" "2010-01-01T00:05:00+00:00"
[3] "2010-01-01T00:10:00+00:00" "2010-01-01T00:15:00+00:00"
[5] "2010-01-01T00:20:00+00:00" "2010-01-01T00:25:00+00:00"
This uses the GMT timezone by default, however, I want to use the EET timezone. I get it using:
date1 <- as.POSIXct(date)
date2 <- format(date1,tz="Europe/Istanbul",usetz=TRUE)
[1] "2010-01-01 02:00:00 EET" "2010-01-01 02:05:00 EET"
[3] "2010-01-01 02:10:00 EET" "2010-01-01 02:15:00 EET"
[5] "2010-01-01 02:20:00 EET" "2010-01-01 02:25:00 EET"
This way, I get the correct timezone. Is there a way that I can get my dates to be presented like 2010-01-01 02:00:00+02:00
? How should I change my code to achieve that?
format_iso_8601(as.POSIXlt(date,tz="EET"))
[1] "2010-01-01T02:00:00+00:00" "2010-01-01T02:05:00+00:00" "2010-01-01T02:10:00+00:00"
[4] "2010-01-01T02:15:00+00:00" "2010-01-01T02:20:00+00:00" "2010-01-01T02:25:00+00:00"