user2963882
user2963882

Reputation: 627

Shiny sliderinput timeformat

I am trying to update a sliderinput with a dateformat, but the the updated version differs from the actual date I am passing in.

shinyUI(sidebarLayout(
    sidebarPanel(
    sliderInput("date_range", 
                     "Choose Date Range:", 
                     min = as.POSIXct("2016-02-01 01:00"),
                     max = as.POSIXct("2016-03-01 23:00"),
                     value = c(as.POSIXct("2016-02-01 02:00")),
                     timeFormat = "%a %H:%M", ticks = F, animate = T
         ))))





 shinyServer(function(session,input, output) {
     observe(
        #min und max date vom tweet map frame auslesen
        Sys.setlocale("LC_TIME", "English")



    time <- as.data.frame(as.POSIXct(df_map$created_at, format="%a %b %d %H:%M:%S +0000 %Y", tz="GMT"))
    names(time)[1]<-"time"
    time %>% arrange(desc(time)) %>% filter(row_number()==1 | row_number()==n()) -> min_max_time



    updateSliderInput(session,"date_range",min = (min_max_time[2,]),
                                           max = (min_max_time[1,]), value=min_max_time[2,])
  }
  ))}

Where the format of df_map$created_at is Mon Jun 06 21:37:23 +0000 2016

In man example min_max_time is

 time
    1 2016-06-07 23:27:11
    2 2016-06-06 21:37:23

But the updated Sliderinput starts at 23:37:23 not 21:37:23

Does the shinyslider uses a different time zone?

Upvotes: 2

Views: 4207

Answers (2)

Sonia
Sonia

Reputation: 339

For some reason only setting timezone = "GMT" suggested above didn't work for me. My solution was:

.POSIXct(as.integer(as.POSIXct(setThisTime, tz = "UTC")), tz = Sys.timezone()),

where setThisTime was a string.

See also: How do you convert dates/times from one time zone to another in R?

Upvotes: 0

user2963882
user2963882

Reputation: 627

Already found the solution: Shiny uses UTC.

But you can pass timezone = "GMT" in the UI Sliderinput.

Upvotes: 1

Related Questions