Learn R Programming

⚠️There's a newer version (1.9.4) of this package.Take me there.

lubridate

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. Specifically, lubridate provides:

  • a set of intuitive date-time related functions that work the same way for all common date-time classes (including those from chron, timeDate, zoo, xts, its, tis, timeSeries, fts, and tseries)

  • quick and easy parsing of date-times: ymd(), dmy(), mdy(), ...

  • simple functions to extract and modify components of a date-time, such as years, months, days, hours, minutes, and seconds: year(), month(), day(), ...

  • helper functions for handling time zones: with_tz(), force_tz()

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

Copy Link

Version

Install

install.packages('lubridate')

Monthly Downloads

916,030

Version

1.5.6

License

GPL-2

Maintainer

Vitalie Spinu

Last Published

April 5th, 2016

Functions in lubridate (1.5.6)

Timespan-class

Timespan class
quick_durations

Quickly create duration objects.
Duration-class

Duration class
Interval-class

Interval class
dst

Get Daylight Savings Time indicator of a date-time.
int_shift

Shift an interval along the timeline
make_difftime

Create a difftime object.
days_in_month

Get the number of days in the month of a date-time.
duration

Create a duration object.
make_datetime

Efficient creation of date-times from numeric representations.
hms

Create a period with the specified hours, minutes, and seconds
month

Get/set months component of a date-time.
am

Does date time occur in the am or pm?
interval

Create an interval object.
int_end

Access and change the end date of an interval
date_decimal

Converts a decimal to a date.
force_tz

Replace time zone to create new date-time
second

Get/set seconds component of a date-time.
int_diff

Extract the intervals within a vector of date-times
fit_to_timeline

Fit a POSIXlt date-time to the timeline
quick_periods

Quickly create period objects.
as.duration

Change an object to a duration.
rollback

Roll back date to last day of previous month
Period-class

Period class
reclass_timespan

Convenience method to reclass timespans post-modification.
today

The current date
decimal_date

Converts a date to a decimal of its year.
minute

Get/set minutes component of a date-time.
guess_formats

Guess formats from the supplied date-time character vector.
week

Get/set weeks component of a date-time.
leap_year

Is a year a leap year?
int_flip

Flip the direction of an interval
origin

1970-01-01 UTC
reclass_date

Convenience method to reclass dates post-modification.
lakers

Lakers 2008-2009 basketball data set
now

The current time
DateUpdate

Changes the components of a date object
period

Create a period object.
int_aligns

Test if two intervals share an endpoint
hm

Create a period with the specified number of hours and minutes
with_tz

Get date-time in a different time zone
int_overlaps

Test if two intervals overlap
year

Get/set years component of a date-time.
is.difftime

Is x a difftime object?
DateCoercion

Convert a variety of date-time classes to POSIXlt and POSIXct
round_date

Round, floor and ceiling methods for date-time objects.
%m+%

Add and subtract months to a date without exceeding the last day of the new month
%within%

Tests whether a date or interval falls within an interval
int_start

Access and change the start date of an interval
time_length

Compute the exact length of a time span.
lubridate-package

Dates and times made easy with lubridate
as.period

Change an object to a period.
is.POSIXt

Is x a POSIXct or POSIXlt object?
Deprecated-lubridate

Deprecated function in lubridate package
date

Get/set Date component of a date-time.
ymd

Parse dates according to the order in that year, month, and day elements appear in the input vector.
parse_date_time

Parse character and numeric date-time vectors with user friendly order formats.
quarter

Get the fiscal quarter of a date-time.
timespan

Description of time span classes in lubridate.
pretty_dates

Computes attractive axis breaks for date-time data
ymd_hms

Parse dates that have hours, minutes, or seconds elements.
int_standardize

Ensures all intervals in an interval object are positive
tz

Get/set time zone component of a date-time.
as.interval

Change an object to an interval.
as_date

Convert an object to a Date
is.Date

Is x a Date object?
is.timespan

Is x a length of time?
int_length

Get the length of an interval in seconds
olson_time_zones

Names of available time zones
here

The current time in your local timezone
is.instant

Is x a date-time object?
ms

Create a period with the specified number of minutes and seconds
stamp

Format dates and times based on human-friendly templates.
day

Get/set days component of a date-time.
hour

Get/set hours component of a date-time.
period_to_seconds

Contrive a period to/from a given number of seconds.