Next →

Output:


      

Plots:

Dates and Times in R

R provides built-in classes to work with dates and times, such as Date and POSIXct/POSIXlt. These allow you to perform calculations, formatting, and comparisons easily.

Creating Dates

my_date <- as.Date("2025-08-14")
my_date

Working with Date-Time

my_datetime <- as.POSIXct("2025-08-14 15:30:00")
my_datetime

Operations on Dates

Formatting Dates

format(my_date, "%B %d, %Y")  # "August 14, 2025"

Working with dates and times is essential for time series analysis, scheduling, and reporting.