Working with Dates and Times in R
Charlotte Wickham
Instructor
ymd()
- year, then month, then dayymd("2013-02-27")
"2013-02-27"
ymd("2013.02.27")
"2013-02-27"
ymd("2013 Feb 27th")
"2013-02-27"
ymd()
,
ydm()
,
mdy()
,
myd()
,
dmy()
,
dym()
dmy("27-02-2013")
"2013-02-27"
mdy("02-27-2013")
"2013-02-27"
dmy_hm("27-02-2013 12:12pm")
"2013-02-27 12:12:00 UTC"
parse_date_time("27-02-2013", order = "dmy")
"2013-02-27 UTC"
parse_date_time(c("27-02-2013", "2013 Feb 27th"),
+ order = c("dmy", "ymd"))
"2013-02-27 UTC" "2013-02-27 UTC"
Character | Meaning |
---|---|
d |
Numeric day of the month |
m |
Month of year |
y |
Year with century |
Y |
Year without century |
H |
Hours (24 hour) |
M |
Minutes |
S |
Seconds |
Character | Meaning |
---|---|
a |
Abbreviated weekday |
A |
Full weekday |
b |
Abbreviate month name |
B |
Full month name |
I |
Hours (12 hour) |
p |
AM/PM |
z |
Timezone, offset from UTC |
Working with Dates and Times in R