In the past I have used a combination of dateInput and a slider to get date and hour for my shiny app. I was wondering if there is a better option available now as I need to col
You can now use the package shinyTime to intuitively input time into a Shiny App. At the moment it works with separate numeric inputs, that together make up time in the %H:%M
or %H:%M:%S
format. Getting and setting the value in R is done with a DateTime object.
Example usage (also see the example on shinyapps):
library(shiny)
library(shinyTime)
ui <- fluidPage(
titlePanel("shinyTime Example App"),
sidebarLayout(
sidebarPanel(
timeInput("time_input", "Enter time", value = strptime("12:34:56", "%T"))
),
mainPanel(
textOutput("time_output")
)
)
)
server <- function(input, output, session) {
output$time_output <- renderText(strftime(input$time_input, "%T"))
}
shinyApp(ui, server)
Disclaimer: I am the package author. Feedback and suggestions most welcome!