lubridate v1.7.9.2


Monthly downloads



Make Dealing with Dates a Little Easier

Functions to work with date-times and time-spans: fast and user friendly parsing of date-time data, extraction and updating of components of a date-time (years, months, days, hours, minutes, and seconds), algebraic manipulation on date-time and time-span objects. The 'lubridate' package has a consistent and memorable syntax that makes working with dates easy and fun. Parts of the 'CCTZ' source code, released under the Apache 2.0 License, are included in this package. See <> for more details.



version R build
status Coverage
Status CRAN RStudio mirror
downloads Development


Date-time data can be frustrating to work with in R. R commands for date-times are generally unintuitive and change depending on the type of date-time object being used. Moreover, the methods we use with date-times must be robust to time zones, leap days, daylight savings times, and other time related quirks, and R lacks these capabilities in some situations. Lubridate makes it easier to do the things R does with date-times and possible to do the things R does not.

If you are new to lubridate, the best place to start is the date and times chapter in R for data science.


# The easiest way to get lubridate is to install the whole tidyverse:

# Alternatively, install just lubridate:

# Or the the development version from GitHub:
# install.packages("devtools")



library(lubridate, warn.conflicts = FALSE)
  • Easy and fast parsing of date-times: ymd(), ymd_hms, dmy(), dmy_hms, mdy(), …

    #> [1] "2010-12-15"
    #> [1] "2017-04-01"
  • Simple functions to get and set components of a date-time, such as year(), month(), mday(), hour(), minute() and second():

    bday <- dmy("14/10/1979")
    #> [1] 10
    wday(bday, label = TRUE)
    #> [1] Sun
    #> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
    year(bday) <- 2016
    wday(bday, label = TRUE)
    #> [1] Fri
    #> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat
  • Helper functions for handling time zones: with_tz(), force_tz()

    time <- ymd_hms("2010-12-13 15:30:30")
    #> [1] "2010-12-13 15:30:30 UTC"
    # Changes printing
    with_tz(time, "America/Chicago")
    #> [1] "2010-12-13 09:30:30 CST"
    # Changes time
    force_tz(time, "America/Chicago")
    #> [1] "2010-12-13 15:30:30 CST"

Lubridate also expands the type of mathematical operations that can be performed with date-time objects. It introduces three new time span classes borrowed from

  • durations, which measure the exact amount of time between two points

  • periods, which accurately track clock times despite leap years, leap seconds, and day light savings time

  • intervals, a protean summary of the time information between two points

Code of Conduct

Please note that the lubridate project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Functions in lubridate

Name Description
am Does date time occur in the am or pm?
Interval-class Interval class
Duration-class Duration class
Period-class Period class
Timespan-class Timespan class
Deprecated-lubridate Deprecated functions in the lubridate package
DateCoercion Convert a variety of date-time classes to POSIXlt and POSIXct
DateTimeUpdate Changes the components of a date object
as.interval Change an object to an interval
as.duration Change an object to a duration
day Get/set days component of a date-time
as.period Change an object to a period
date_decimal Converts a decimal to a date
is.Date Various date utilities
duration Create a duration object.
fit_to_timeline Fit a POSIXlt date-time to the timeline
local_time Get local time from a date-time vector.
cyclic_encoding Cyclic encoding of date-times
format_ISO8601_precision_check Provide a format for ISO8601 dates and times with the requested precision.
date Get/set date component of a date-time
guess_formats Guess possible date-times formats from a character vector
days_in_month Get the number of days in the month of a date-time
leap_year Is a year a leap year?
parse_date_time User friendly date-time parsing functions
quarter Get the fiscal quarter and semester of a date-time
make_difftime Create a difftime object.
reclass_date Convenience method to reclass dates post-modification.
pretty_dates Computes attractive axis breaks for date-time data
stamp Format dates and times based on human-friendly templates
as_date Convert an object to a date or date-time
reclass_timespan Convenience method to reclass timespans post-modification.
ymd Parse dates with year, month, and day components
period Create or parse period objects
ymd_hms Parse date-times with year, month, and day, hour, minute, and second components.
time_length Compute the exact length of a time span
period_to_seconds Contrive a period to/from a given number of seconds
ms Parse periods with hour, minute, and second components
hidden_aliases Internal page for hidden aliases
force_tz Replace time zone to create new date-time
is.difftime Is x a difftime object?
decimal_date Converts a date to a decimal of its year
dst Get daylight savings time indicator of a date-time
is.POSIXt Various POSIX utilities
minute Get/set minutes component of a date-time
format_ISO8601 Format in ISO8601 character format
timespan Description of time span classes in lubridate
%within% Does a date (or interval) fall within an interval?
year Get/set years component of a date-time
lakers Lakers 2008-2009 basketball data set
tz Get/set time zone component of a date-time
interval Utilities for creation and manipulation of Interval objects
is.timespan Is x a length of time?
lubridate-package Dates and times made easy with lubridate
%m+% Add and subtract months to a date without exceeding the last day of the new month
hour Get/set hours component of a date-time
rollbackward Roll backward or forward a date the previous, current or next month
month Get/set months component of a date-time
reexports Objects exported from other packages
now The current day and time
make_datetime Efficient creation of date-times from numeric representations
is.instant Is x a date-time object?
origin 1970-01-01 UTC
round_date Round, floor and ceiling methods for date-time objects
second Get/set seconds component of a date-time
with_tz Get date-time in a different time zone
week Get/set weeks component of a date-time
No Results!

Vignettes of lubridate

No Results!

Last month downloads


Type Package
License GPL (>= 2)
LinkingTo Rcpp
VignetteBuilder knitr
Encoding UTF-8
LazyData true
RoxygenNote 7.1.1
SystemRequirements A system with zoneinfo data (e.g. /usr/share/zoneinfo) as well as a recent-enough C++11 compiler (such as g++-4.8 or later). On Windows the zoneinfo included with R is used.
Collate 'Dates.r' 'POSIXt.r' 'RcppExports.R' 'util.r' 'parse.r' 'timespans.r' 'intervals.r' 'difftimes.r' 'durations.r' 'periods.r' 'accessors-date.R' 'accessors-day.r' 'accessors-dst.r' 'accessors-hour.r' 'accessors-minute.r' 'accessors-month.r' 'accessors-quarter.r' 'accessors-second.r' 'accessors-tz.r' 'accessors-week.r' 'accessors-year.r' 'am-pm.r' 'time-zones.r' 'numeric.r' 'coercion.r' 'constants.r' 'cyclic_encoding.r' 'data.r' 'decimal-dates.r' 'deprecated.r' 'format_ISO8601.r' 'guess.r' 'hidden.r' 'instants.r' 'leap-years.r' 'ops-addition.r' 'ops-compare.r' 'ops-division.r' 'ops-integer-division.r' 'ops-m+.r' 'ops-modulo.r' 'ops-multiplication.r' 'ops-subtraction.r' 'package.r' 'pretty.r' 'round.r' 'stamp.r' 'update.r' 'vctrs.R' 'zzz.R'
NeedsCompilation yes
Packaged 2020-11-11 19:57:49 UTC; vspinu
Repository CRAN
Date/Publication 2020-11-13 15:30:02 UTC

Include our badge in your README