{
"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."
}
}
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"]}'
{
"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."
}
}
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"}'
{
"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."
}
}
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"]}'
{
"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."
}
}
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"}'
{
"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."
}
}
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'
{
"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)."
}
}
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"}'
{
"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."
}
}
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'
{
"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."
}
}
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 访问密钥,这是一个唯一的字母和数字组合,用于访问我们的 API 端点。要使用 日期差异和工作日 API 进行身份验证,只需在 Authorization 标头中包含您的 bearer token。
| 标头 | 描述 |
|---|---|
授权
|
必需
应为 Bearer access_key. 订阅后,请查看上方的"您的 API 访问密钥"。
|
日期差异、自定义周末和节假日的工作日计算、采用月末截断的时长运算、时区转换、ISO 周信息以及 ISO 8601 时长
默认情况下,计数包括开始日期之后、截至并包括结束日期的工作日。因此,周一到周五的差值为 4,而从周一开始加上 4 个工作日会得到周五,所以差值和加法结果一致。将 includeStart 设为 true,也将开始日期计入,如电子表格中的 NETWORKDAYS 函数
是的。将 weekendDays 作为 0–6 的数字(0 = 星期日)或“Fri”和“Sat”等名称传入。将 holidays 作为最多 366 个 YYYY-MM-DD 格式的日期传入。API 不包含内置节假日日历,因此你需要发送适用于你的日期。
结果会限制为目标月份的最后一个有效日期:2025-02-28,闰年则为 2024-02-29。发生这种情况时,响应会将 clamped 设为 true。2 月 29 日加一年得到 2 月 28 日 .
向 diff 或 add 传入一个 IANA 时区。天和月保持墙上时间不变,而小时、分钟和秒则按实际经过的时间计算。纽约的春季跳时日是 1 个日历日,但只有 23 小时。不存在的本地时间会按时间间隔向前移动,重复的本地时间则解析为较早的时刻。这两种情况都会被标记。
ISO 8601 日期(YYYY-MM-DD)和日期时间(YYYY-MM-DDTHH:MM[:SS[.fff]]),可选带有 Z 或正负 HH:MM 偏移量,年份范围为 0001-9999。如果传入 timeZone,则没有偏移量的值会按该时区读取,否则按 UTC 读取。像 2026-02-29 这样的无效日期会返回 400 错误,并附有清晰的说明。
年和月的长度各不相同,因此 parse-duration 使用它们的平均值(每年 365.2425 天,每月 30.436875 天),并将 totalSecondsApproximate 设为 true。要获得精确结果,请使用 add 端点将时长加到一个实际的开始日期上
ISO 8601 周:每周从星期一开始,第 1 周包含当年的第一个星期四。例如,2021-01-03 属于周序年 2020 的第 53 周。响应中包含 isoWeek 和 isoWeekYear 乐彩
范围和偏移最多可达 200 年,节假日列表最多可包含 366 个日期,工作日步长最多可达正负 50,000,请求正文最多可达 32 KiB。超出这些限制的请求将返回 400 错误并指出相应限制
它返回规范化的开始值和结束值、方向、精确到周的秒数总计、完整的日历月和日历年、日历天数、包含 ISO 时长的日历分解以及工作日结果。工作日详情包括周末规则以及跳过的周末和节假日数量
该端点先应用年和月,再根据本地挂钟时间应用周和天,随后将小时、分钟和秒作为经过的时间应用。响应包含已应用的组成部分、多种格式的结果、星期几、Unix 时间戳、钳制状态以及 DST 间隙调整状态
它会返回原始日期、该日期是否为工作日、请求的偏移量、结果日期和星期、跨越的日历日数、周末设置,以及跳过的周末和节假日数量。偏移天数为零时返回未变更的开始日期;开始日期永远不计入。
响应包含 UTC 时刻和 Unix 时间戳,以及源时区和目标时区对象。每个对象都提供本地日期时间、带偏移量的 ISO 值、以分钟为单位的偏移量、夏令时标志、缩写和格式化文本。它还报告偏移量差异以及本地时间是否存在歧义或不存在的标志
对于给定日期,返回星期、ISO 星期和周日期、ISO 周和周所属年份、一年中的第几天、剩余天数、季度、是否为闰年、该月和该年的天数、是否为周末,以及该日期开始时 UTC 午夜的 Unix 时间戳
解析器返回原始时长和规范化时长、其正负号,以及分别表示年、月、周、日、小时、分钟和秒的组成部分。它还会返回总秒数。涉及年或月的总数是近似值;在固定时长规则下,周、日和更小单位的总数是精确值
格式化端点会返回输入的秒数、选定的最大单位、ISO 时长字符串以及各组成部分的分解。它们使用周、天、小时、分钟和秒,从不使用月或年。例如,5400 秒会转换为 PT1H30M,小数秒会四舍五入到毫秒。
使用 ISO 字符串以实现互操作,使用结构化组件进行计算和显示,并在系统要求使用纪元秒时使用 Unix 时间戳。对于时长,存储或传输时使用 ISO 值,面向用户的标签则使用组件。将结果视为普遍精确之前,请检查近似、钳制和 DST 标志