Date Difference and Business Days API

API ID 15186

Date differences, business days with custom weekends and holidays, duration math with month-end clamping, time zone conversion, ISO week info, and ISO 8601 durations.

58 ms avg response

API Documentation

Endpoints

Request
Exact totals (seconds to weeks), whole calendar months and years, a calendar breakdown (years, months, days, hours, minutes, seconds), and business days. Inputs without an offset are read in timeZone when given, otherwise UTC. Range limit: 200 years.
Endpoint ID: 40604
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40604/difference+between+two+dates
INPUT PARAMETERS

Difference between two dates — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "start": "2026-11-02T00:00:00Z",
        "end": "2026-12-01T17:30:00Z",
        "timeZone": null,
        "direction": "forward",
        "totals": {
            "seconds": 2568600,
            "minutes": 42810,
            "hours": 713.5,
            "days": 29.729167,
            "weeks": 4.247024,
            "months": 0,
            "years": 0
        },
        "calendarDays": 29,
        "calendar": {
            "years": 0,
            "months": 0,
            "days": 29,
            "hours": 17,
            "minutes": 30,
            "seconds": 0,
            "iso": "P29DT17H30M"
        },
        "businessDays": 20,
        "businessDayDetails": {
            "convention": "Counts business days after the start date up to and including the end date.",
            "weekendDays": [
                "Sunday",
                "Saturday"
            ],
            "weekendDaysSkipped": 8,
            "holidaysSkipped": 1
        },
        "note": "Inputs without a UTC offset are read in timeZone when given, otherwise as UTC. Calendar math (months, days) runs on wall-clock time; hours, minutes, and seconds are exact elapsed time. totals.months and totals.years are whole calendar units; the other totals are exact elapsed time."
    }
}
Difference between two dates — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40604/difference+between+two+dates' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"start":"2026-11-02","end":"2026-12-01T17:30:00Z","holidays":["2026-11-26"]}'

    
Request
Adds years and months first (clamped to the last day of the month, so Jan 31 + 1 month = Feb 28 or 29), then weeks and days on the wall clock, then hours, minutes, and seconds as exact time. Pass timeZone for DST-aware results.
Endpoint ID: 40605
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40605/add+or+subtract+a+duration
INPUT PARAMETERS

Add or subtract a duration — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": "2024-01-31T00:00:00Z",
        "timeZone": null,
        "duration": "P1M2DT3H",
        "applied": {
            "years": 0,
            "months": 1,
            "weeks": 0,
            "days": 2,
            "hours": 3,
            "minutes": 0,
            "seconds": 0
        },
        "result": "2024-03-02T03:00:00Z",
        "resultIso": "2024-03-02T03:00:00Z",
        "resultUtc": "2024-03-02T03:00:00.000Z",
        "resultDate": "2024-03-02",
        "weekday": "Saturday",
        "unixTimestamp": 1709348400,
        "clamped": true,
        "adjustedForDstGap": false,
        "note": "Adding months or years clamps to the last valid day of the target month (for example, Jan 31 + 1 month = Feb 28, or Feb 29 in a leap year). Order: years and months, then weeks and days on the wall clock, then hours, minutes, and seconds as exact elapsed time."
    }
}
Add or subtract a duration — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40605/add+or+subtract+a+duration' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"date":"2024-01-31","duration":"P1M2DT3H"}'

    
Request
Moves forward (or backward for negative days) skipping weekend days and holidays. The start date is not counted. Days must be within ±50,000 and the result within 200 years of the start.
Endpoint ID: 40606
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40606/add+business+days+to+a+date
INPUT PARAMETERS

Add business days to a date — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "start": "2026-11-25",
        "startIsBusinessDay": true,
        "days": 3,
        "result": "2026-12-01",
        "weekday": "Tuesday",
        "calendarDaysSpanned": 6,
        "weekendDays": [
            "Sunday",
            "Saturday"
        ],
        "weekendDaysSkipped": 2,
        "holidaysSkipped": 1,
        "note": "The start date is not counted. Each step moves to the next (or previous, for negative days) date that is not a weekend day or holiday. With days = 0 the start date is returned unchanged. Uses the calendar date of the input; any time or offset is ignored."
    }
}
Add business days to a date — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40606/add+business+days+to+a+date' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"date":"2026-11-25","days":3,"holidays":["2026-11-26"]}'

    
Request
Converts between IANA time zones. Returns the UTC instant, UTC offsets, DST flags, abbreviations, and a formatted local string. A datetime without an offset needs from. Flags local times that are ambiguous (DST fall-back) or nonexistent (spring-forward gap).
Endpoint ID: 40607
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40607/convert+a+date-time+between+time+zones
INPUT PARAMETERS

Convert a date-time between time zones — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": "2026-07-01T12:00:00",
        "utc": "2026-07-01T16:00:00.000Z",
        "unixTimestamp": 1782921600,
        "from": {
            "timeZone": "America/New_York",
            "localDateTime": "2026-07-01T12:00:00",
            "iso": "2026-07-01T12:00:00-04:00",
            "offset": "-04:00",
            "offsetMinutes": -240,
            "isDST": true,
            "abbreviation": "EDT",
            "formatted": "Wednesday, July 1, 2026 at 12:00:00 PM EDT"
        },
        "to": {
            "timeZone": "Europe/London",
            "localDateTime": "2026-07-01T17:00:00",
            "iso": "2026-07-01T17:00:00+01:00",
            "offset": "+01:00",
            "offsetMinutes": 60,
            "isDST": true,
            "abbreviation": "GMT+1",
            "formatted": "Wednesday, July 1, 2026 at 5:00:00 PM GMT+1"
        },
        "offsetDifferenceMinutes": 300,
        "ambiguousLocalTime": false,
        "nonexistentLocalTime": false,
        "note": "Uses the Intl time zone database of the runtime. A local time repeated by a DST fall-back resolves to the earlier instant; a local time skipped by a spring-forward gap moves forward by the gap."
    }
}
Convert a date-time between time zones — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40607/convert+a+date-time+between+time+zones' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"datetime":"2026-07-01T12:00:00","from":"America/New_York","to":"Europe/London"}'

    
Request
ISO week number and week-year, day of year, quarter, weekday, leap year, days in month and year, and the Unix timestamp at midnight UTC.
Endpoint ID: 40608
GET https://zylalabs.com/api/15186/date+difference+and+business+days+api/40608/calendar+facts+for+a+date
INPUT PARAMETERS

Calendar facts for a date — Endpoint Features

Object Description
date Required ISO date YYYY-MM-DD

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

date
API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "date": "2024-02-29",
        "year": 2024,
        "month": 2,
        "monthName": "February",
        "day": 29,
        "weekday": "Thursday",
        "weekdayNumber": 4,
        "isoWeekday": 4,
        "isoWeek": 9,
        "isoWeekYear": 2024,
        "isoWeekDate": "2024-W09-4",
        "dayOfYear": 60,
        "daysRemainingInYear": 306,
        "quarter": 1,
        "isLeapYear": true,
        "daysInMonth": 29,
        "daysInYear": 366,
        "isWeekend": false,
        "unixTimestamp": 1709164800,
        "note": "unixTimestamp is midnight UTC at the start of this date, in seconds."
    }
}
Calendar facts for a date — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40608/calendar+facts+for+a+date?date=2024-02-29' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Splits a duration such as P1Y2M3DT4H5M6S, P2W, or -PT1.5H into components and total seconds. Years and months use average lengths and are flagged approximate.
Endpoint ID: 40609
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40609/parse+an+iso+8601+duration
INPUT PARAMETERS

Parse an ISO 8601 duration — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": "P1DT2H3M4.5S",
        "normalized": "P1DT2H3M4.5S",
        "negative": false,
        "components": {
            "years": 0,
            "months": 0,
            "weeks": 0,
            "days": 1,
            "hours": 2,
            "minutes": 3,
            "seconds": 4.5
        },
        "totalSeconds": 93784.5,
        "totalSecondsApproximate": false,
        "note": "Exact: weeks are 7 days, days are 24 hours (DST shifts are not applied without a start date)."
    }
}
Parse an ISO 8601 duration — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40609/parse+an+iso+8601+duration' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"duration":"P1DT2H3M4.5S"}'

    
Request
Same as the POST version, with query parameters.
Endpoint ID: 40610
GET https://zylalabs.com/api/15186/date+difference+and+business+days+api/40610/format+duration+from+query+seconds
INPUT PARAMETERS

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

This endpoint does not require any input parameters.

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "seconds": 5400,
        "largestUnit": "hours",
        "iso": "PT1H30M",
        "components": {
            "years": 0,
            "months": 0,
            "weeks": 0,
            "days": 0,
            "hours": 1,
            "minutes": 30,
            "seconds": 0
        },
        "note": "Months and years are never emitted because their length varies. Seconds are rounded to milliseconds."
    }
}
Format duration from query seconds — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40610/format+duration+from+query+seconds' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Turns a number of seconds into an ISO 8601 duration using weeks, days, hours, minutes, and seconds (never months or years). Limit: 200 years of seconds.
Endpoint ID: 40611
POST https://zylalabs.com/api/15186/date+difference+and+business+days+api/40611/format+seconds+as+an+iso+8601+duration
INPUT PARAMETERS

Format seconds as an ISO 8601 duration — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "seconds": 93784.25,
        "largestUnit": "days",
        "iso": "P1DT2H3M4.25S",
        "components": {
            "years": 0,
            "months": 0,
            "weeks": 0,
            "days": 1,
            "hours": 2,
            "minutes": 3,
            "seconds": 4.25
        },
        "note": "Months and years are never emitted because their length varies. Seconds are rounded to milliseconds."
    }
}
Format seconds as an ISO 8601 duration — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15186/date+difference+and+business+days+api/40611/format+seconds+as+an+iso+8601+duration' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"seconds":93784.25}'

    

API Access Key & Authentication

After signing up, every developer is assigned a personal API access key, a unique combination of letters and digits provided to access to our API endpoint. To authenticate with the Date Difference and Business Days API simply include your bearer token in the Authorization header.

Headers
Header Description
Authorization Required Should be Bearer access_key. See "Your API Access Key" above when you are subscribed.

No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.

Starts at
$10,000/Year


  • Custom Volume
  • Custom Rate Limit
  • Specialized Customer Support
  • Real-Time API Monitoring

Overview

Date differences, business days with custom weekends and holidays, duration math with month-end clamping, time zone conversion, ISO week info, and ISO 8601 durations.

Date Difference and Business Days API FAQs

By default, the count includes business days after the start date, up to and including the end date. A Monday-to-Friday diff is therefore 4, and adding 4 business days to Monday gives Friday, so diff and add agree. Set includeStart to true to also count the start date, as in spreadsheet NETWORKDAYS.

Yes. Pass weekendDays as numbers 0–6 (0 = Sunday) or names such as "Fri" and "Sat". Pass holidays as up to 366 dates in YYYY-MM-DD format. The API does not include a built-in holiday calendar, so you send the dates that apply to you.

The result is clamped to the last valid day of the target month: 2025-02-28, or 2024-02-29 in a leap year. The response sets clamped to true when this happens. Feb 29 plus one year gives Feb 28.

Pass an IANA timeZone to diff or add. Days and months keep the wall-clock time, and hours, minutes, and seconds are exact elapsed time. The spring-forward day in New York is 1 calendar day but 23 hours. Nonexistent local times move forward by the gap, and repeated local times resolve to the earlier instant. Both cases are flagged.

ISO 8601 dates (YYYY-MM-DD) and date-times (YYYY-MM-DDTHH:MM[:SS[.fff]]) with an optional Z or plus/minus HH:MM offset, for years 0001-9999. Values without an offset are read in timeZone when you pass one, otherwise as UTC. Invalid dates such as 2026-02-29 return a 400 with a clear message.

Years and months vary in length, so parse-duration uses averages for them (365.2425 days per year, 30.436875 days per month) and sets totalSecondsApproximate to true. For an exact result, add the duration to a real start date with the add endpoint.

The ISO 8601 week: weeks start on Monday, and week 1 contains the year's first Thursday. For example, 2021-01-03 is in week 53 of week-year 2020. The response includes both isoWeek and isoWeekYear.

Ranges and shifts can be up to 200 years, holiday lists up to 366 dates, business-day steps up to plus or minus 50,000, and request bodies up to 32 KiB. Requests outside these limits return a 400 that names the limit.

It returns the normalized start and end values, direction, exact totals in seconds through weeks, whole calendar months and years, calendar-day count, a calendar breakdown with an ISO duration, and business-day results. Business-day details include the weekend convention and skipped weekend and holiday counts.

The endpoint applies years and months first, then weeks and days using the local wall clock, followed by hours, minutes, and seconds as elapsed time. The response includes the applied components, result in multiple formats, weekday, Unix timestamp, clamping status, and DST-gap adjustment status.

It returns the original date, whether it was a business day, the requested shift, resulting date and weekday, calendar days spanned, weekend configuration, and counts of skipped weekends and holidays. A zero-day shift returns the start date unchanged; the start date is never counted.

The response includes the UTC instant and Unix timestamp, plus source and destination time-zone objects. Each object provides the local date-time, ISO value with offset, offset in minutes, DST flag, abbreviation, and formatted text. It also reports the offset difference and ambiguous or nonexistent local-time flags.

For a date, it returns the weekday, ISO weekday and week date, ISO week and week-year, day of year, remaining days, quarter, leap-year status, days in the month and year, weekend status, and the Unix timestamp for midnight UTC at the start of that date.

The parser returns the original and normalized duration, its sign, and separate years, months, weeks, days, hours, minutes, and seconds components. It also returns total seconds. Totals involving years or months are approximate; weeks, days, and smaller units are exact under fixed-duration rules.

The formatting endpoints return the input seconds, selected largest unit, ISO duration string, and component breakdown. They use weeks, days, hours, minutes, and seconds, never months or years. For example, 5,400 seconds becomes PT1H30M, and fractional seconds are rounded to milliseconds.

Use ISO strings for interoperability, structured components for calculations and display, and Unix timestamps for systems that require epoch seconds. For durations, use the ISO value for storage or transport and components for user-facing labels. Check approximation, clamping, and DST flags before treating results as universally exact.

General FAQs

To obtain your API key, first sign in to your account and navigate to the API you want to use. From the API's Pricing section, choose a plan and complete the subscription process. Once subscribed, return to the API page and you will see your API Access Key displayed at the top of the documentation page. You can use this key to authenticate your requests.

You can’t switch APIs during the free trial. If you subscribe to a different API, your trial will end and the new subscription will start as a paid plan.

The free trial lasts for 7 days and allows you to make up to 50 API requests.

No, the free trial is available only once, so we recommend using it on the API that interests you the most. Most of our APIs offer a free trial, but some may not include this option.

Yes. If the API offers a free trial, you will see a "Free 7-Day Trial" option in its Pricing section. The trial lasts for 7 days and allows up to 50 API requests, enabling you to evaluate the API before subscribing to a paid plan.

Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.

Prices are listed in USD (United States Dollar), EUR (Euro), CAD (Canadian Dollar), AUD (Australian Dollar), and GBP (British Pound). We accept all major debit and credit cards. Our payment system uses the latest security technology and is powered by Stripe, one of the world's most reliable payment companies. If you have any trouble paying by card, just contact us at [email protected]

Additionally, if you already have an active subscription in any of these currencies (USD, EUR, CAD, AUD, GBP), that currency will remain for subsequent subscriptions. You can change the currency at any time as long as you don't have any active subscriptions.
The local currency shown on the pricing page is based on the country of your IP address and is provided for reference only. The actual prices are in USD (United States Dollar). When you make a payment, the charge will appear on your card statement in USD, even if you see the equivalent amount in your local currency on our website. This means you cannot pay directly with your local currency.
Occasionally, a bank may decline the charge due to its fraud protection settings. We suggest reaching out to your bank initially to check if they are blocking our charges. Also, you can access the Billing Portal and change the card associated to make the payment. If these does not work and you need further assistance, please contact our team at [email protected]
Prices are determined by a recurring monthly or yearly subscription, depending on the chosen plan.
API calls are deducted from your plan based on successful requests. Each plan comes with a specific number of calls that you can make per month. Only successful calls, indicated by a Status 200 response, will be counted against your total. This ensures that failed or incomplete requests do not impact your monthly quota.
Zyla API Hub works on a recurring monthly subscription system. Your billing cycle will start the day you purchase one of the paid plans, and it will renew the same day of the next month. So be aware to cancel your subscription beforehand if you want to avoid future charges.
To upgrade your current subscription plan, simply go to the pricing page of the API and select the plan you want to upgrade to. The upgrade will be instant, allowing you to immediately enjoy the features of the new plan. Please note that any remaining calls from your previous plan will not be carried over to the new plan, so be aware of this when upgrading. You will be charged the full amount of the new plan.
To check how many API calls you have left for the current month, refer to the 'X-Zyla-API-Calls-Monthly-Remaining' field in the response header. For example, if your plan allows 1,000 requests per month and you've used 100, this field in the response header will indicate 900 remaining calls.

You can monitor your API usage through the response headers included with every request:

x-zyla-api-calls-monthly-used: Shows the total number of API requests you have used during the current billing period.
x-zyla-api-calls-monthly-remaining: Shows the number of API requests you have remaining for the current billing period.

The 'X-Zyla-RateLimit-Reset' header shows the number of seconds until your rate limit resets. This tells you when your request count will start fresh. For example, if it displays 3,600, it means 3,600 seconds are left until the limit resets.

Yes, you can cancel your subscription at any time. Simply go to the Pricing section of the API you're subscribed to and click the "Unsubscribe" button.

Please note that upgrades, downgrades, and cancellations take effect immediately. Once your subscription is canceled, access to the service will end immediately, regardless of any remaining API calls in your quota.

After 7 days, you will be charged the full amount for the plan you were subscribed to during the trial. Therefore, it's important to cancel before the trial period ends. Refund requests for forgetting to cancel on time are not accepted.
When you subscribe to an API free trial, you can make up to 50 API calls. If you wish to make additional API calls beyond this limit, the API will prompt you to perform an "Start Your Paid Plan." You can find the "Start Your Paid Plan" button in your profile under Subscription -> Choose the API you are subscribed to -> Pricing tab.
You can contact us through our chat channel to receive immediate assistance. We are always online from 8 am to 5 pm (EST). If you reach us after that time, we will get back to you as soon as possible. Additionally, you can contact us via email at [email protected]

Please have a look at our Refund Policy: https://zylalabs.com/terms#refund


Related APIs