Make working with dates in R just that little bit easier


License: GPL-3.0

Language: R

Keywords: date, date-time, r


Build Status Coverage Status CRAN RStudio mirror downloads Development version CRAN version


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")


  • 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 http://joda.org.

  • 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

Project Statistics

Sourcerank 18
Repository Size 5.86 MB
Stars 442
Forks 152
Watchers 43
Open issues 59
Dependencies 15
Contributors 49
Tags 18
Last updated
Last pushed

Top Contributors See all

Garrett Grolemund Vitalie Spinu Hadley Wickham Ian Lyttle Imanuel Costigan Christophe Dervieux Jason Law Joe Thorley Doug Mitarotonda Lorenz Walthert Joseph Albert HK Cheng Kirill Müller Elliott Sales de Andrade Sergio Oller Jonathan Boiser Chel Hee Lee Christopher Gandrud Will Beasley Jean-Olivier Irisson

Packages Referencing this Repo

Make Dealing with Dates a Little Easier
Latest release 1.7.4 - Updated - 442 stars

Recent Tags See all

v1.7.3 February 27, 2018
v1.7.2 February 07, 2018
v1.7.1 November 02, 2017
v1.7.0 October 30, 2017
before-CCTZ May 02, 2017
v1.6.0 September 12, 2016
v1.5.6 April 05, 2016
v1.5.0 December 02, 2015
stamp_fail May 13, 2015
v1.4.0 December 14, 2014
v1.3.3 January 01, 2014
v1.3.0 April 18, 2013
v1.2.0 September 14, 2012
v1.1.0 March 01, 2012
v0.2.6 January 02, 2012

Something wrong with this page? Make a suggestion

Last synced: 2018-04-11 10:27:30 UTC

Login to resync this repository