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

898,204

Version

1.6.0

License

GPL-2

Maintainer

Vitalie Spinu

Last Published

September 13th, 2016

Functions in lubridate (1.6.0)

date

Get/set Date component of a date-time.
as.period

Change an object to a period.
date_decimal

Converts a decimal to a date.
guess_formats

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

Converts a date to a decimal of its year.
Duration-class

Duration class
duration

Create a duration object.
hidden_aliases

Internal page for hidden aliases
force_tz

Replace time zone to create new date-time
Deprecated-lubridate

Deprecated function in lubridate package
dst

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

Fit a POSIXlt date-time to the timeline
days_in_month

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

Lakers 2008-2009 basketball data set
is.POSIXt

Is x a POSIXct or POSIXlt object?
is.Date

Is x a Date object?
ms

Create a period with the specified hours, minutes, and seconds
is.difftime

Is x a difftime object?
is.instant

Is x a date-time object?
hour

Get/set hours component of a date-time.
Interval-class

Interval class
interval

Utilities for creation and manipulation of Interval objects.
is.timespan

Is x a length of time?
month

Get/set months component of a date-time.
%m+%

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

The current time
make_datetime

Efficient creation of date-times from numeric representations
origin

1970-01-01 UTC
period_to_seconds

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

Is a year a leap year?
lubridate-package

Dates and times made easy with lubridate
make_difftime

Create a difftime object.
minute

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

Get the fiscal quarter and semester of a date-time.
reclass_date

Convenience method to reclass dates post-modification.
quick_durations

Quickly create duration objects.
reclass_timespan

Convenience method to reclass timespans post-modification.
round_date

Round, floor and ceiling methods for date-time objects.
rollback

Roll back date to last day of previous month
pretty_dates

Computes attractive axis breaks for date-time data
Period-class

Period class
quick_periods

Quickly create period objects.
period

Create a period object.
Timespan-class

Timespan class
%within%

Tests whether a date or interval falls within an interval
tz

Get/set time zone component of a date-time.
time_length

Compute the exact length of a time span.
second

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

The current date
week

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

Description of time span classes in lubridate.
stamp

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

Get date-time in a different time zone
year

Get/set years component of a date-time.
ymd_hms

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

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

Convert an object to a date or date-time
DateCoercion

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

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

Does date time occur in the am or pm?
DateUpdate

Changes the components of a date object
as.interval

Change an object to an interval.
as.duration

Change an object to a duration.
parse_date_time

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