Working with dateInput in Shiny



This is my first post to the R community, and I suspect my question may be immediately obvious to anyone who views it (and I'm also worried this may be an R question, and not a Shiny question per say). Nonetheless, I cannot figure it out. I'm working on a Shiny form using the excellent template provided by Dean Attali ( Using Dean's example (code here:, let's just add a single field, a date input:

dateInput("date", label = "Date:", format = "mm/dd/yyyy")

Now, I update fieldsAll (line 4) so the date will be displayed in the table that is rendered:

fieldsAll <- c("name", "date", "favourite_pkg", "used_shiny", "r_num_years", "os_type")

However, the date appears in a format I do not recognize. For example, the date 01/07/2019 displays in the table as 17903. I would like this to display the same as it is entered, how can this be accomplished? My first thought was that on the server side, the output$responseTable should be modified (added line 228), e.g.:

data$date <- as.POSIXct(data$date, ...)

But I'm not sure what should be set for origin here since I do not recognize the format. Any insight would be greatly appreciated!



Clearly I needed to put in more time learning about date formatting in R. The following works when inserted into the output$responsesTable section of code on the server side:

data$date <- format(as.Date(data$date, origin="1970-01-01"), "%m/%d/%Y")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.