| lt_date | R Documentation |
Format date or datetime columns using JavaScript's native Date methods.
The underlying data should be Date or POSIXt in R (serialized as
new Date(...) for the browser).
lt_date(x, columns, method = NULL, locale = NULL, options = NULL)
x |
An |
columns |
Column selection (formula, character, or numeric). |
method |
A JS Date method name to call (e.g., |
locale |
A BCP 47 locale string (e.g., |
options |
A named list of
|
x with the date formatting recorded.
The formatted date may differ from the input date depending on the
viewer's local timezone. JavaScript's new Date("2024-01-15") parses
date-only strings as UTC midnight, but toLocaleDateString() converts to
the local timezone. For example, 2024-01-15 will display as
2024-01-14 for a viewer at GMT-6. To avoid this, pass
options = list(timeZone = "UTC").
d = data.frame(
event = c("Launch", "Update"),
date = as.Date(c("2024-01-15", "2024-06-30"))
)
lt(d) |> lt_date(~ date)
lt(d) |> lt_date(~ date, options = list(year = "numeric", month = "short"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.