Reputation: 187
I've build this dashboard with multiple date and time columns however in the dashboard the "T" and "Z" popup in the display Any ideas on how to remove this? I tried
as.character
, as.factor
, anytime
but I'm not able to make it happen.
Any other ideas are appreciated!
Upvotes: 4
Views: 3137
Reputation: 736
This happens when you go from R to Javascript. You need to add:
output$yourDT <- DT::renderDataTable({
DT::datatable(df) %>% formatDate(3, "toLocaleString")
})
Where the 3 represents the position of the date (as.POSIXct(), not factor, for example) column (e.g., third column) you are formatting.
Upvotes: 5
Reputation: 5109
You can parse it in base R or with lubridate :
tz <- Sys.timezone()
date1 <- "2015-03-23T13:23:20Z"
# With {base}
strptime(date1, tz = tz, format = "%Y-%m-%dT%H:%M:%OSZ")
[1] "2015-03-23 13:23:20 CET"
#With lubridate
lubridate::ymd_hms(date1, tz = tz)
[1] "2015-03-23 14:23:20 CET"
You can of course specify a different timezone for tz
.
Best,
Colin
Upvotes: 1