Operations (sample payloads)
Main operations
Add to date
Add a number of duration types to a time value. Returns a UTC ISO string. Sample Input
\{
"date": "2023-05-15T10:30:00Z",
"years": 1,
"months": 2,
"weeks": 3,
"days": 4,
"business_days": 5,
"hours": 6,
"minutes": 7,
"seconds": 8
\}
Sample Output
{
"result": "2024-08-12T16:37:08Z"
}
Compare dates
Compare two date/time values. Sample Input
\{
"date_a": "2023-05-15T10:30:00Z",
"comparison": "IS BEFORE",
"date_b": "2023-05-16T09:45:00Z",
"resolution": "day"
\}
Sample Output
{
"result": true
}
Compare times
Compare two time values, ignoring the dates/days. Sample Input
{
"datetime": "2023-05-15T14:30:00Z",
"comparison": "IS BEFORE",
"time": \{
"hour": "15",
"minute": "00",
"second": "00"
\},
"timezone": "America/New_York",
"include_seconds": true
}
Sample Output
{
"result": true
}
Date is in the last...
Allows you to easily check if a given date has occurred in the last X number of seconds, minutes, hours, or days. Sample Input
\{
"date": "2023-05-15T10:30:00Z",
"in_last": 2,
"in_last_unit": "days"
\}
Sample Output
{
"result": true
}
Format date
Format date to a desired format. Sample Input
{
"date": "2023-05-15T14:30:00Z",
"format": {
"existing_format": "YYYY-MM-DD HH:mm:ss Z"
},
"timezone": "America/New_York"
}
Sample Output
{
"result": "2023-05-15 10:30:00 -0400"
}
Get current timestamp
Returns the current date and time in a date string format (ISO 8601). Sample Input
{
"timezone": "America/New_York",
"format": {
"existing_format": "YYYY-MM-DDTHH:mm:ssZ"
}
}
Sample Output
{
"result": "2023-05-15T14:30:45-0400"
}
Get date property
Returns a number value from a date, such as the year, the day of the month, or the hour of the day. Sample Input
\{
"date": "2023-05-15T14:30:45Z",
"parameter": "month"
\}
Sample Output
{
"result": 5
}
Get day of week
Returns the day of the week for a given date. e.g. "Saturday" or "Tuesday" Sample Input
\{
"date": "2023-05-15T14:30:00Z",
"timezone": "America/New_York"
\}
Sample Output
{
"result": "Monday"
}
Get days between
Get the number of days between two dates, rounded to the nearest day. If the second date is before the first date, the result will be negative. Sample Input
\{
"date1": "2023-05-01T00:00:00Z",
"date2": "2023-05-15T12:30:00Z"
\}
Sample Output
{
"result": 14
}
Get duration
Given a total number of seconds, minutes, etc - return human readable text containing how long the duration was approximately, in the units of your choosing. Sample Input
\{
"duration": 7200,
"unit_type": "seconds"
\}
Sample Output
{
"result": "2 hours"
}
Get time between
Get the time between two dates, as hh:mm:ss. If the second date is before the first date, the result will be negative. Sample Input
\{
"start_date": "2023-05-01T09:00:00Z",
"end_date": "2023-05-03T15:30:45Z"
\}
Sample Output
{
"result": \{
"years": 0,
"months": 0,
"days": 2,
"hours": 6,
"minutes": 30,
"seconds": 45,
"milliseconds": 0
\}
}
Get time from now
Returns a human readable date relative to the current time, such as "in 2 months", or "4 days ago". Sample Input
{
"date": "2023-07-15T10:30:00Z"
}
Sample Output
{
"result": "in 2 months"
}
Is between dates?
Check to see whether a date falls within a date range Sample Input
\{
"date": "2023-05-15T10:30:00Z",
"start_date": "2023-05-01T00:00:00Z",
"end_date": "2023-05-31T23:59:59Z",
"inclusive": true,
"resolution": "day"
\}
Sample Output
{
"result": true
}
Is between times?
Check to see whether a time falls within a time range, ignoring the dates/days. Sample Input
{
"datetime": "2023-05-15T14:30:00Z",
"start_time": \{
"hour": "09",
"minute": "00",
"second": "00"
\},
"end_time": \{
"hour": "18",
"minute": "00",
"second": "00"
\},
"timezone": "America/New_York",
"include_seconds": true,
"inclusive": true
}
Sample Output
{
"result": true
}
Is business hours?
Check to see if it's business hours or not, given a date in a given timezone. Sample Input
{
"date": "2023-05-15T14:30:00Z",
"week_start": "1",
"week_end": "5",
"hours_start": \{
"hour": "09",
"minute": "00"
\},
"hours_end": \{
"hour": "17",
"minute": "00"
\},
"timezone": "America/New_York"
}
Sample Output
Is weekend?
Check to see if it's the weekend or not, given a date in a given timezone. Sample Input
\{
"date": "2023-05-20T14:30:00Z",
"timezone": "America/New_York"
\}
Sample Output
{
"result": true
}
Minus from date
Subtract a number of duration types from a time value. Returns a UTC ISO string. Sample Input
\{
"date": "2023-05-15T10:30:00Z",
"years": 1,
"months": 2,
"weeks": 3,
"days": 4,
"business_days": 5,
"hours": 6,
"minutes": 7,
"seconds": 8
\}
Sample Output
{
"result": "2022-02-28T04:22:52Z"
}