A Time Input Widget for Shiny

Provides a time input widget for Shiny. This widget allows intuitive time input in the '[hh]:[mm]:[ss]' or '[hh]:[mm]' (24H) format by using a separate numeric input for each time component. The interface with R uses date-time objects. See the project page for more information and examples.

Build Status

This package provides a timeInput widget for Shiny. This widget allows intuitive time input in the [hh]:[mm]:[ss] or [hh]:[mm] (24H) format by using a separate numeric input for each time component. Setting and getting of the time in R is done with 'DateTimeClasses' objects.


As the shinyTime package mimics the existing shiny functionality, using the package is easy. Some examples of adding an input widget to the UI:

ui <- fluidPage(
  timeInput("time1", "Time:"),

  # Set to current time
  timeInput("time2", "Time:", value = Sys.time()),

  # Set to custom time 
  timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
  # Use %H:%M format
  timeInput("time4", "Time:", seconds = FALSE)

Note that setting an inital value is done with a DateTime object, in the same way as setting a date in dateInput can be done with a Date object.

The value retrieved will also be a DateTime object. You need to convert it to character to be able to print the time, as the default character representation does not include it. An example:

server <- function(input, output) {
  # Print the time in [hh]:[mm]:[ss] everytime it changes
  observe(print(strftime(input$time1, "%T")))
  # Print the time in [hh]:[mm] everytime it changes
  observe(print(strftime(input$time4, "%R")))

For a fully functional app go to the ShinyApps example (can be a bit slow) or try the shinyTime::shinyTimeExample() function after installing the package with install.packages('shinyTime').


Change log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
Also Keep a CHANGELOG.


0.2.1 - 2016-10-07


  • Updated style to match other shiny inputs
  • Added input validation so that the time returned is always a valid time (invalid values are set to 0)

0.2.0 - 2016-07-20


  • Support for input in the %H:%M format (without seconds)


  • Fixed padding problem on keyboard input
  • Keyboard input now properly causes change events

0.1.0 - 2016-07-18


  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0.1 by Gerhard Burger, 2 years ago

https://burgerga.github.io/shinyTime/, https://github.com/burgerga/shinyTime

Report a bug at https://github.com/burgerga/shinyTime/issues

Browse source code at https://github.com/cran/shinyTime

Authors: Gerhard Burger [aut, cre]

Documentation:   PDF Manual  

GPL-3 | file LICENSE license

Imports htmltools, shiny

Suggests testthat, spelling

Imported by edeaR.

Suggested by xROI.

See at CRAN