I am developing a Shiny application and am encountering an issue with the date display in a sliderInput widget. Instead of displaying dates in the format “YYYY-MM-DD”, it is showing Unix timestamps in milliseconds. I have tried several troubleshooting steps including inspecting HTML elements, checking for JavaScript errors (none found), and simplifying the code to the minimum, but nothing has resolved the issue so far. Here is the minimal code to reproduce the problem:
`library(shiny)
ui <- fluidPage(
sliderInput("date_range",
"Select Date Range:",
min = as.Date("1998-12-01"),
max = as.Date("2023-09-01"),
value = c(as.Date("2020-01-01"), as.Date("2021-01-01")),
timeFormat = "%Y-%m-%d",
sep = "",
width = "100%")
)
server <- function(input, output, session) {
observe({
print(as.Date(input$date_range[1], origin = "1970-01-01"))
print(as.Date(input$date_range[2], origin = "1970-01-01"))
})
}
shinyApp(ui, server)`
Screenshot of my rshiny
When I run the app, the dates in the R console are correct, but the display in the browser shows timestamps (e.g., “912470400000”) instead of formatted dates.
Here is a screenshot of the inspected element:
I am looking for suggestions or solutions to ensure the dates are displayed correctly in sliderInput. I am using R version 4.3.2 et and Shiny version 1.8.1.1 Any help would be greatly appreciated!
Thank you in advance for your assistance.