Formats inputs as ISO 8601 calendar dates (`"YYYY-MM-DD"`).
Value
A character vector the same length as `x` (or `NULL` if `x` is `NULL`) with dates formatted as `"YYYY-MM-DD"`. Unparseable elements or `NA`s become `NA_character_`.
Details
Coercion uses [base::as.Date()], so time-of-day and timezone information are dropped. For `POSIXct` inputs, the date is computed by `as.Date.POSIXct` (which uses `tz = "UTC"` by default). Be aware that ambiguous character dates (e.g., `"01/02/2024"`) depend on your R locale/format unless you specify a format before calling this function.
Examples
as_iso_date(Sys.Date())
#> [1] "2026-02-05"
as_iso_date(NULL)
#> NULL
as_iso_date("not-a-date")
#> NULL
