| timeInput {shinyTime} | R Documentation |
Create a time input
Description
Creates a time widget that consists of separate numeric inputs for the hours, minutes, and
seconds. The input and output values of the time widget are instances of
DateTimeClasses, these can be converted to and from character strings with
strptime and strftime.
Additionally, the input can be specified as a character string in the 'hh:mm:ss' format or an
hms class. For a simple example app see shinyTimeExample.
Usage
timeInput(inputId, label, value = NULL, seconds = TRUE, minute.steps = NULL)
Arguments
inputId |
The |
label |
Display label for the control, or |
value |
The desired time value. Must be a instance of |
seconds |
Show input for seconds. Defaults to TRUE. |
minute.steps |
Round time to multiples of |
Value
Returns a POSIXlt object, which can be converted to
a POSIXct object with as.POSIXct for more efficient storage.
See Also
strptime, strftime, DateTimeClasses
Other shinyTime functions:
shinyTimeExample(),
updateTimeInput()
Examples
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
# Default value is 00:00:00
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")),
# Set to custom time using hms
timeInput("time4", "Time:", value = hms::as_hms("23:45:07")),
# Set to custom time using character string
timeInput("time5", "Time:", value = "21:32:43"),
# Use hh:mm format
timeInput("time6", "Time:", seconds = FALSE),
# Use multiples of 5 minutes
timeInput("time7", "Time:", minute.steps = 5)
)
shinyApp(ui, server = function(input, output) { })
}