{
  "id": "hours",
  "version": "703ff6bb992e",
  "status": "published",
  "name": "Hours Calculator",
  "question": "How many hours between times?",
  "summary": "Counts the hours and minutes between two clock times, as decimal hours for timesheets, with an end time before the start counted on the next day.",
  "category": "days",
  "subcategory": "time-and-hours",
  "url": "https://www.acalculator.org/days/hours-calculator",
  "markdown": "https://www.acalculator.org/days/hours-calculator.md",
  "kind": "function",
  "method": "minutes = end − start in minutes, plus 24 × 60 when the end is earlier than the start; hours = minutes ÷ 60.",
  "assumptions": [
    "Times are on a 24-hour clock with no date. An end time earlier than the start time is on the next day, so the answer is always under 24 hours.",
    "The same start and end time gives 0 hours.",
    "Clock changes for daylight saving time are not counted: every hour is 60 minutes."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "start": {
        "title": "Start time",
        "description": "The time the period starts.",
        "type": "string",
        "pattern": "^\\d{2}:\\d{2}(:\\d{2})?$"
      },
      "end": {
        "title": "End time",
        "description": "The time the period ends. A time earlier than the start is on the next day.",
        "type": "string",
        "pattern": "^\\d{2}:\\d{2}(:\\d{2})?$"
      }
    }
  },
  "outputs": {
    "hours": {
      "label": "Hours",
      "description": "The time between the start and the end in decimal hours: minutes ÷ 60.",
      "format": "number"
    },
    "time": {
      "label": "Hours and minutes",
      "description": "The time between the start and the end in whole hours and minutes.",
      "format": "duration"
    },
    "minutes": {
      "label": "Minutes",
      "description": "The time between the start and the end in minutes.",
      "format": "integer"
    },
    "nextDay": {
      "label": "Ends the next day",
      "description": "Yes when the end time is earlier than the start time, so the period runs past midnight.",
      "format": "boolean"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "start": "09:00",
      "end": "17:30"
    },
    "outputs": {
      "hours": 8.5,
      "time": {
        "hours": 8,
        "minutes": 30
      },
      "minutes": 510,
      "nextDay": false
    },
    "text": "From 9:00 AM to 5:30 PM is 8.5 hours (510 minutes)."
  },
  "examples": [
    {
      "given": {
        "start": "09:00",
        "end": "17:30"
      },
      "expect": {
        "hours": 8.5,
        "time": {
          "hours": 8,
          "minutes": 30
        },
        "minutes": 510,
        "nextDay": false
      },
      "source": "hand calculation in content.mdx: 17:30 − 9:00 = 8 h 30 min = 510 ÷ 60 = 8.5 hours"
    },
    {
      "given": {
        "start": "22:00",
        "end": "06:15"
      },
      "expect": {
        "hours": 8.25,
        "time": {
          "hours": 8,
          "minutes": 15
        },
        "minutes": 495,
        "nextDay": true
      },
      "source": "hand calculation in content.mdx: 6:15 + 24:00 − 22:00 = 8 h 15 min"
    },
    {
      "given": {
        "start": "08:40",
        "end": "12:05"
      },
      "expect": {
        "hours": 3.4166666666666665,
        "time": {
          "hours": 3,
          "minutes": 25
        },
        "minutes": 205
      },
      "source": "hand calculation in content.mdx: 12:05 − 8:40 = 3 h 25 min = 205 ÷ 60 = 3.4167 hours"
    },
    {
      "given": {
        "start": "13:45",
        "end": "13:45"
      },
      "expect": {
        "hours": 0,
        "minutes": 0,
        "nextDay": false
      },
      "source": "hand calculation in content.mdx: the same time is 0 hours"
    }
  ],
  "sources": [
    "NIST Special Publication 811 (2008), Guide for the Use of the International System of Units: 1 h = 60 min = 3,600 s. https://www.nist.gov/pml/special-publication-811"
  ],
  "related": [
    "time-duration",
    "work-hours",
    "time-card",
    "time"
  ],
  "changelog": []
}
