lubridate (version 1.7.4)

as_date: Convert an object to a date or date-time


Convert an object to a date or date-time


as_date(x, ...)

# S4 method for ANY as_date(x, ...)

# S4 method for POSIXt as_date(x, tz = NULL)

# S4 method for numeric as_date(x, origin = lubridate::origin)

# S4 method for character as_date(x, tz = NULL, format = NULL)

as_datetime(x, ...)

# S4 method for POSIXt as_datetime(x, tz = "UTC")

# S4 method for numeric as_datetime(x, origin = lubridate::origin, tz = "UTC")

# S4 method for character as_datetime(x, tz = "UTC", format = NULL)

# S4 method for ANY as_datetime(x, tz = "UTC")



a vector of POSIXt, numeric or character objects


further arguments to be passed to specific methods (see above).


a time zone name (default: time zone of the POSIXt object x). See OlsonNames().


a Date object, or something which can be coerced by as.Date(origin, ...) to such an object (default: the Unix epoch of "1970-01-01"). Note that in this instance, x is assumed to reflect the number of days since origin at "UTC".


format argument for character methods. When supplied parsing is performed by strptime(). For this reason consider using specialized parsing functions in lubridate.


a vector of Date objects corresponding to x.

Compare to base R

These are drop in replacements for as.Date() and as.POSIXct(), with a few tweaks to make them work more intuitively.

  • as_date() ignores the timezone attribute, resulting in a more intuitive conversion (see examples)

  • Both functions provide a default origin argument for numeric vectors.

  • as_datetime() defaults to using UTC.


Run this code
dt_utc <- ymd_hms("2010-08-03 00:50:50")
dt_europe <- ymd_hms("2010-08-03 00:50:50", tz="Europe/London")
c(as_date(dt_utc), as.Date(dt_utc))
c(as_date(dt_europe), as.Date(dt_europe))
## need not supply origin
# }

Run the code above in your browser using DataLab