I am having issues extracting the correct character values from a POSIXct datetime object using strftime(). The dput() of my sample data is below:
dput(df1)
structure(list(FlowDate3 = structure(c(1388534400, 1388534400,
1388534400, 1388534400, 1388534400, 1388534400, 1388534400, 1388534400,
1388534400, 1388534400), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
FlowDate4 = c("2013-12-31", "2013-12-31", "2013-12-31", "2013-12-31",
"2013-12-31", "2013-12-31", "2013-12-31", "2013-12-31", "2013-12-31",
"2013-12-31")), .Names = c("FlowDate3", "FlowDate4"), row.names = c(NA,
10L), class = "data.frame")
Looks like this:
> df1
FlowDate3 FlowDate4
1 2014-01-01 2013-12-31
2 2014-01-01 2013-12-31
3 2014-01-01 2013-12-31
4 2014-01-01 2013-12-31
5 2014-01-01 2013-12-31
6 2014-01-01 2013-12-31
7 2014-01-01 2013-12-31
8 2014-01-01 2013-12-31
9 2014-01-01 2013-12-31
10 2014-01-01 2013-12-31
> str(df1)
'data.frame': 10 obs. of 2 variables:
$ FlowDate3: POSIXct, format: "2014-01-01" "2014-01-01" "2014-01-01" ...
$ FlowDate4: chr "2013-12-31" "2013-12-31" "2013-12-31" "2013-12-31" ...
To create FlowDate4 I did the following:
> strftime(df1$FlowDate3, "%Y-%m-%d")
[1] "2013-12-31" "2013-12-31" "2013-12-31" "2013-12-31" "2013-12-31" "2013-12-31"
[7] "2013-12-31" "2013-12-31" "2013-12-31" "2013-12-31"
Which, as you can see is yielding the wrong character strings for the date in FlowDate3... the year, month, and date are off. I've ran around in numerous circles trying to figure out why and am at a complete loss. strftime() is not behaving as I've experienced in the past. Any help is appreciated.