Time Between Calculator

Time Between Calculator API

Utilities

Calculate time differences between two dates and times instantly. Get results in years, months, days, hours, minutes, and seconds with detailed breakdowns.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

120 requests per minute

Endpoints

1 endpoint available

Overview

Find the time between two dates, with optional times of day. The result, inside data, gives the total difference in milliseconds, seconds, minutes, hours, days and weeks, the number of whole calendar months and years, a years/months/days/hours/minutes/seconds breakdown, and a readable sentence.

Notes

  • Dates use YYYY-MM-DD. Times use 24-hour HH:MM or HH:MM:SS and default to 00:00.
  • Dates and times are read as UTC. data.start and data.end echo them back as ISO timestamps.
  • The difference is always positive: swapping start and end gives the same result.
  • The totals (seconds to weeks) are rounded down.
  • months and years count whole calendar months and years. breakdown and humanReadable use average lengths (a year is 365.25 days and a month is 1/12 of that), so they can differ from a calendar count by a day or two.
  • A date that does not exist (e.g. 2025-02-30) or an impossible time (e.g. 25:00) returns 400.

Endpoints

POST
https://opentools.ca/api/v1/tools/time-between-calculator
Calculate the time between two dates and times

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
startDate
string
Required
Start date as YYYY-MM-DD.
startTime
string
OptionalStart time as HH:MM or HH:MM:SS (24-hour, UTC).Default: 00:00
endDate
string
Required
End date as YYYY-MM-DD.
endTime
string
OptionalEnd time as HH:MM or HH:MM:SS (24-hour, UTC).Default: 00:00

Response Example

{
  "success": true,
  "data": {
    "humanReadable": "2 months, 12 days, 11 hours, and 30 minutes",
    "milliseconds": 6337800000,
    "seconds": 6337800,
    "minutes": 105630,
    "hours": 1760,
    "days": 73,
    "weeks": 10,
    "months": 2,
    "years": 0,
    "start": "2025-01-01T09:00:00.000Z",
    "end": "2025-03-15T17:30:00.000Z",
    "breakdown": {
      "years": 0,
      "months": 2,
      "days": 12,
      "hours": 11,
      "minutes": 30,
      "seconds": 0
    }
  }
}

Error Codes

400
Invalid request. Validation problems are listed in details.
401
Missing or invalid API key
403
API key is deactivated or expired, or this IP address is not allowed for the key
429
Rate limit exceeded (120 requests per minute per key)
500
Internal server error

Code Examples

curl -X POST https://opentools.ca/api/v1/tools/time-between-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "2025-01-01",
    "startTime": "09:00",
    "endDate": "2025-03-15",
    "endTime": "17:30"
  }'

Ready to get started?

Create an API key to start using the Time Between Calculator API.

Rather use it in your browser? Open the Time Between Calculator