I'm looking to create a sequence of time stamps starting and ending at a specific date for every three hours. The ways that I have tried work well, but all have the same problem. Somewhere in the middle of the sequence there is a time conversion between PST to PDT and I am not sure why. Below are the codes that I have tried, similar to the questions asked on this site beforehand (Question1 and Question2):
TIME1 <- as.POSIXct( "2000-01-01 02:00:00", tz = "America/Los_Angeles")
TIME2 <- as.POSIXct( "2016-02-29 23:00:00" , tz = "America/Los_Angeles")
temp <- seq(from = TIME1, to = TIME2, by = "3 hours")
When I look at the output of temp
, it looks good at first except when looking at the specified interval below
temp[720:745]
[1] "2000-03-30 23:00:00 PST" "2000-03-31 02:00:00 PST" "2000-03-31 05:00:00 PST" "2000-03-31 08:00:00 PST" "2000-03-31 11:00:00 PST" "2000-03-31 14:00:00 PST"
[7] "2000-03-31 17:00:00 PST" "2000-03-31 20:00:00 PST" "2000-03-31 23:00:00 PST" "2000-04-01 02:00:00 PST" "2000-04-01 05:00:00 PST" "2000-04-01 08:00:00 PST"
[13] "2000-04-01 11:00:00 PST" "2000-04-01 14:00:00 PST" "2000-04-01 17:00:00 PST" "2000-04-01 20:00:00 PST" "2000-04-01 23:00:00 PST" "2000-04-02 03:00:00 PDT"
[19] "2000-04-02 06:00:00 PDT" "2000-04-02 09:00:00 PDT" "2000-04-02 12:00:00 PDT" "2000-04-02 15:00:00 PDT" "2000-04-02 18:00:00 PDT" "2000-04-02 21:00:00 PDT"
[25] "2000-04-03 00:00:00 PDT" "2000-04-03 03:00:00 PDT"
Notice on line [1]
of the output, it goes from "2000-03-30 23:00:00 PST" to "2000-03-31 02:00:00 PST" which is 3 hours, but on line [13]
it goes from "2000-04-01 23:00:00 PST" to "2000-04-02 03:00:00 PDT". Notice the time zone change there. This happens throughout the sequence. Any ideas how to avoid such a result? I believe it is converting automatically for me the daylight savings time, which I don't want. If I can keep it as LST (local standard time), that will be great.
UPDATE: I have found recently this suggestion, where we just convert to timezone "UTC" to do away with daylight savings time. It works, just marks all time stamps as UTC. However, it would be nice to see if there is still a way to keep it as LST.