VOOZH about

URL: https://www.geeksforgeeks.org/r-language/calculate-time-difference-between-dates-in-r-programming-difftime-function/

⇱ Calculate Time Difference between Dates in R Programming - difftime() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Calculate Time Difference between Dates in R Programming - difftime() Function

Last Updated : 15 Jul, 2025

difftime() function in R Language is used to calculate time difference between dates in the required units like seconds, minutes, days, weeks, etc.

Syntax: difftime(date1, date2, units)
Parameters:date1, date2: Dates to calculate difference
units: seconds, minutes, days, weeks

Example 1:


Output:

Time difference of 122 days
Time difference of 17.42857 weeks

Example 2:

Output:

Time difference of 2928 hours
Time difference of 175680 mins
Comment
Article Tags:

Explore