daterangepicker (version 0.1.0)

daterangepicker: daterangepicker

Description

The Date Range Picker pops up two calendars for selecting dates, times, or predefined ranges like "Yesterday", "Last 30 Days", etc.

Usage

daterangepicker(
  inputId = NULL,
  label = "Select a Date",
  start = NULL,
  end = NULL,
  min = NULL,
  max = NULL,
  ranges = NULL,
  language = "en",
  style = "width:100%;border-radius:4px;text-align:center;",
  class = NULL,
  icon = NULL,
  options = daterangepickerOptions()
)

Arguments

inputId

The input ID

label

The label for the control, or NULL for no label.

start

The beginning date of the initially selected. Must be a Date / POSIXt or string. If NULL will default to the current day.

end

The end date of the initially selected date range. Must be a Date / POSIXt or string. If NULL will default to the current day.

min

The earliest date a user may select. Must be a Date or string

max

The latest date a user may select. Must be a Date or string

ranges

Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range.

language

The language used for month and day names. Default is "en". See the Multiple Locale Support for a list of other valid values.

style

Add CSS-styles to the input.

class

Custom class

icon

Icon to display next to the label.

options

List of further options. See daterangepickerOptions

See Also

www.daterangepicker.com

Other daterangepicker Functions: daterangepickerOptions(), updateDaterangepicker()

Examples

Run this code
if (interactive()) {
library(shiny)
library(daterangepicker)

## UI ##########################
ui <- fluidPage(
  tags$head(tags$style(".myclass {background-color: #96dafb;}")),
  daterangepicker(
    inputId = "daterange",
    label = "Pick a Date",
    start = Sys.Date() - 30, end = Sys.Date(),
    max = Sys.Date(),
    language = "en",
    ranges = list("Today" = Sys.Date(),
                  "Yesterday" = Sys.Date() - 1,
                  "Last 3 days" = c(Sys.Date() - 2, Sys.Date()),
                  "Last 7 days" = c(Sys.Date() - 6, Sys.Date())
    ),
    style = "width:100%; border-radius:4px",
    class = "myclass",
    icon = icon("calendar")
  ),
  verbatimTextOutput("print"),
  actionButton("act", "Update Daterangepicker"),
)

## SERVER ##########################
server <- function(input, output, session) {
  output$print <- renderPrint({
    req(input$daterange)
    input$daterange
  })
  observeEvent(input$act, {
    updateDaterangepicker(session, "daterange",
                          start = Sys.Date(),
                          end = Sys.Date() - 100)
  })
}
shinyApp(ui, server)
}

Run the code above in your browser using DataLab