lubridate (version 1.1.0)

parse_date: Change dates into a POSIXct format

Description

parse_date is an internal function for the ymd family of functions. Its recommended to use these functions instead. It transforms dates stored in character and numeric vectors to POSIXct objects. All inputed dates are considered to have the same order and to use the same separator.

Usage

parse_date(x, formats, quiet = FALSE,
    seps = find_separator(x), tz = "UTC")

Arguments

x
a character or numeric vector of suspected dates
formats
a vector of date-time format elements in the order they occur within the dates. See strptime for format elements.
quiet
logical. When TRUE function evalueates without displaying customary messages.
seps
a vector of possible characters used to separate elements within the dates.
tz
a character string that specifies the time zone with which to parse the dates

Value

  • a vector of POSIXct date-time objects

See Also

ymd

Examples

Run this code
x <- c("09-01-01", "09-01-02", "09-01-03")
parse_date(x, c("%y", "%m", "%d"), seps = "-")
#  "2009-01-01 UTC" "2009-01-02 UTC" "2009-01-03 UTC"
ymd(x)
#  "2009-01-01 UTC" "2009-01-02 UTC" "2009-01-03 UTC"

Run the code above in your browser using DataLab