This code should show me yesterday as date for start and end with today as the last option. It worked for several month, I did not change anything, but since some weeks I get the wrong date.
It shows me the day before yesterday if I run this code locally, rstudio on my ubuntu server or connect to shiny server running this code.
Sys.setenv(TZ='GMT')
shinyApp(
ui <- basicPage(
dateRangeInput("daterange", "Daterange",start = Sys.Date()-1
,end = Sys.Date()-1,max=Sys.Date())
),
server <- function(input,output){}
)
I found this question, In Shiny for R, why does Sys.Date() return yesterday's date inside a dateInput?, and with start=NULL,end=NULL I get correctly today, but as I need yesterday this is no solution for me.
If I run Sys.Date() in the console it gives me the right date, locally and on my server. The problem only occurs if I run this as a shiny app.
Update 21.10.2015
I tried a bit around thanks to Oskar Forsmo's suggestion to get system("date") inside the app, which gives me the correct date and time.
And it gets even more strange:
library(shiny)
values <- reactiveValues()
shinyApp(
ui <- basicPage(
uiOutput("timerange"),
textOutput( "today" )
),
server <- function(input,output){
isolate(values$day <- Sys.Date())
output$today <- renderText({
as.character(values$day-1)
})
output$timerange <- renderUI({ dateRangeInput("daterange", "Daterange",start = values$day-1
,end = values$day-1,max=values$day) })
})
In the output object "today" I have the correct date, in the uiOutput "timerange" I have the wrong day, it shows again the day before yesterday.
I'm gonna provide a screenshot, because I would not believe myself.
wrong day in dateRangeInput, right in textOutput
And on top of that, the app run on shiny server shows the correct time/date to some of my collegues and some get the same wrong date.
To isolate the error, as I have the correct day in renderText there must be a problem somewhere with the dateRangeInput object which is triggered by my desktop?!
Update 29.10.2015
I did not change anything on the code/server but it shows now the correct date, have no idea why but it works as of today.. if anybody have an idea why this happens i would really appreciate to know.
Sys.timezone()
– Pork Chopsystem("date")
from inside the shiny app? – RmIu