ymd_hms

0th

Percentile

Parse dates that have hours, minutes, or seconds elements

Transforms dates stored as character vectors in year, month, day, hour, minute, second format to POSIXct objects. ymd_hms() type functions recognize all non-alphanumeric separators of length 1 with the exception of ".". ymd_hms() functions automatically assigns the Universal Coordinated Time Zone (UTC) to the parsed date. This time zone can be changed with force_tz. ymdThms() specifically handles combined dates and times written in the ISO 8601 format.

Keywords
parse, POSIXt
Usage
ymd_hms(..., quiet = FALSE, tz = "UTC")
Arguments
...
a character vector of dates in year, month, day, hour, minute, second format
quiet
logical. When TRUE function evalueates without displaying customary messages.
tz
a character string that specifies which time zone to parse the date with. The string must be a time zone that is recognized by the user's OS.
Value

  • a vector of POSIXct date-time objects

See Also

ymd, hms

Aliases
  • dmy_h
  • dmy_hm
  • dmy_hms
  • mdy_h
  • mdy_hm
  • mdy_hms
  • ydm_h
  • ydm_hm
  • ydm_hms
  • ymd_h
  • ymd_hm
  • ymd_hms
  • ymdThms
Examples
x <- c("2010-04-14-04-35-59", "2010-04-01-12-00-00")
ymd_hms(x)
# [1] "2010-04-14 04:35:59 UTC" "2010-04-01 12:00:00 UTC"
y <- c("2011-12-31 12:59:59", "2010-01-01 12:00:00")
ymd_hms(y)
# [1] "2011-12-31 12:59:59 UTC" "2010-01-01 12:00:00 UTC"
Documentation reproduced from package lubridate, version 1.1.0, License: GPL

Community examples

Looks like there are no examples yet.