This is a simple question. I want to create in my app an input similar to dateRangeInput, however besides YYY-MM-DD I also want for it to let me pick the the exact hour, minutes and second from the range, is there any method in shiny like this? I can't seem to find it on google.
I could just make a text input but I like the interface provided by dateRangeInput
You can set the variable type to POSIXct, here's an example:
library(shiny)
# ui.R
ui <- shinyUI(fluidPage(
title = 'Initial run of time range update breaks sliderInput',
fluidRow(
column(width = 12,
sliderInput("timeRange", label = "Time range",
min = as.POSIXct("2011-06-04 12:00:00"),
max = as.POSIXct("2011-08-10 14:00:00"),
value = c(as.POSIXct("2011-06-04 12:00:00"),
as.POSIXct("2011-08-10 14:00:00"))),
actionButton("update", "Update range")
)
)))
server <- shinyServer(function(input, output, session) {
output$from <- renderText(input$timeRange[1]);
output$to <- renderText(input$timeRange[2]);
observe({
input$update;
updateSliderInput(session, "timeRange", value =
c(as.POSIXct("2011-06-14
12:00:00"), as.POSIXct("2011-08-01 14:00:00")));
})
})
runApp(list(ui = ui,server = server))
Output:
enter image description here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With