Skip to content

Date/time parsing

ymd() ydm() mdy() myd() dmy() dym() yq() ym() my()
Parse dates with year, month, and day components
ymd_hms() ymd_hm() ymd_h() dmy_hms() dmy_hm() dmy_h() mdy_hms() mdy_hm() mdy_h() ydm_hms() ydm_hm() ydm_h()
Parse date-times with year, month, and day, hour, minute, and second components.
ms() hm() hms()
Parse periods with hour, minute, and second components
parse_date_time() parse_date_time2() fast_strptime()
User friendly date-time parsing functions
guess_formats()
Guess possible date-times formats from a character vector

Setting, getting, and rounding

year() `year<-`() isoyear() epiyear()
Get/set years component of a date-time
quarter() semester()
Get the fiscal quarter and semester of a date-time
month() `month<-`()
Get/set months component of a date-time
week() `week<-`() isoweek() epiweek()
Get/set weeks component of a date-time
day() mday() wday() qday() yday() `day<-`() `mday<-`() `qday<-`() `wday<-`() `yday<-`()
Get/set days component of a date-time
hour() `hour<-`()
Get/set hours component of a date-time
minute() `minute<-`()
Get/set minutes component of a date-time
second() `second<-`()
Get/set seconds component of a date-time
tz() `tz<-`()
Get/set time zone component of a date-time

Date-time helpers

as_date() as_datetime()
Convert an object to a date or date-time
cyclic_encoding()
Cyclic encoding of date-times
date() `date<-`()
Get/set date component of a date-time
decimal_date()
Converts a date to a decimal of its year
is.Date() Date() NA_Date_
Various date utilities
is.POSIXt() is.POSIXlt() is.POSIXct() POSIXct() NA_POSIXct_
Various POSIX utilities
is.instant() is.timepoint()
Is x a date-time object?
make_datetime() make_date()
Efficient creation of date-times from numeric representations
now() today()
The current day and time
origin
1970-01-01 UTC

Durations

A ‘duration’ is a timespan measured in seconds.

duration() dseconds() dminutes() dhours() ddays() dweeks() dmonths() dyears() dmilliseconds() dmicroseconds() dnanoseconds() dpicoseconds() is.duration()
Create a duration object.
is.difftime()
Is x a difftime object?
make_difftime()
Create a difftime object.
as.duration()
Change an object to a duration
Duration-class durations
Duration class

Periods

A ‘period’ is a timespan defined in civil time (human) units like years, months, and days.

period() is.period() seconds() minutes() hours() days() weeks() years() milliseconds() microseconds() nanoseconds() picoseconds() months(<numeric>)
Create or parse period objects
period_to_seconds() seconds_to_period()
Contrive a period to/from a given number of seconds
as.period()
Change an object to a period
Period-class
Period class

Intervals

An interval is a timespan defined by two date-times.

interval() `%--%` is.interval() int_start() `int_start<-`() int_end() `int_end<-`() int_length() int_flip() int_shift() int_overlaps() int_standardize() int_aligns() int_diff()
Utilities for creation and manipulation of Interval objects
as.interval()
Change an object to an interval
`%within%`
Does a date (or interval) fall within an interval?
Interval-class intervals
Interval class

Timespans

Timespans are the generic concept that underlies durations, periods, and intervals.

timespan timespans
Description of time span classes in lubridate
time_length()
Compute the exact length of a time span
is.timespan()
Is x a length of time?

Formatters

stamp() stamp_date() stamp_time()
Format dates and times based on human-friendly templates
format_ISO8601()
Format in ISO8601 character format

Other modification functions

update(<POSIXt>)
Changes the components of a date object
fit_to_timeline()
Fit a POSIXlt date-time to the timeline
with_tz()
Get date-time in a different time zone
force_tz() force_tzs()
Replace time zone to create new date-time
round_date() floor_date() ceiling_date()
Round, floor and ceiling methods for date-time objects
pretty_dates()
Computes attractive axis breaks for date-time data
rollbackward() rollback() rollforward()
Roll backward or forward a date the previous, current or next month
`%m+%` add_with_rollback()
Add and subtract months to a date without exceeding the last day of the new month
local_time()
Get local time from a date-time vector.

Other date-time components

am() pm()
Does date time occur in the am or pm?
days_in_month()
Get the number of days in the month of a date-time
dst()
Get daylight savings time indicator of a date-time
leap_year()
Is a year a leap year?
date_decimal()
Converts a decimal to a date

Data

lakers
Lakers 2008-2009 basketball data set