A lightweight REST API that calculates a missing date value given any two of start, end, and duration,
with a unit of days, weeks, months, or business (Mon–Fri).
https://www.promptbox.cn/api/date.php
GET and POST (JSON or form)
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
start |
string (YYYY-MM-DD) | No (need any two) | 2025-01-01 | Start date |
end |
string (YYYY-MM-DD) | No (need any two) | 2025-01-31 | End date |
duration |
integer | No (need any two) | 30 | Duration amount (≥ 0) |
unit |
string | No | days | One of days, weeks, months, business. Default: days |
{
"start": "2025-01-01",
"duration": 30,
"unit": "days"
}
{
"success": true,
"data": {
"start": "2025-01-01",
"end": "2025-01-31",
"duration": 30,
"unit": "days"
}
}
{
"success": false,
"error": "Please provide at least two of: start, end, duration."
}
GET /api/date.php?start=2025-01-01&duration=30&unit=days
{
"success": true,
"data": {
"start": "2025-01-01",
"end": "2025-01-31",
"duration": 30,
"unit": "days"
}
}
GET /api/date.php?end=2025-04-07&duration=2&unit=weeks
{
"success": true,
"data": {
"start": "2025-03-24",
"end": "2025-04-07",
"duration": 2,
"unit": "weeks"
}
}
GET /api/date.php?start=2025-01-15&end=2025-04-10&unit=months
{
"success": true,
"data": {
"start": "2025-01-15",
"end": "2025-04-10",
"duration": 3,
"unit": "months"
}
}
POST /api/date.php
Content-Type: application/json
{
"start": "2025-01-02",
"duration": 5,
"unit": "business"
}
{
"success": true,
"data": {
"start": "2025-01-02",
"end": "2025-01-09",
"duration": 5,
"unit": "business"
}
}
GET /api/date.php?unit=days
{
"success": false,
"error": "Please provide at least two of: start, end, duration."
}
start, end, duration; the API computes the third.months uses calendar month difference (similar to the UI in date.html).business treats Monday–Friday as working days; weekends are skipped when counting/adding.YYYY-MM-DD; other formats may parse but are not guaranteed.GET and POST.