POST /format_datetime • Credits: 0.5 credits per call
Format Datetime parses one date string or one Unix timestamp, converts it to a target time zone, and returns the result in 18 date fields. The format parameter controls the main output string and accepts Python strftime tokens or a Go layout. Each call costs 0.5 credits.
What does Format Datetime do?
Enrichment data arrives in many date shapes. A LinkedIn scrape returns 2026-05-07T09:14:40.056Z, a CRM export returns 05/07/2026, and a webhook returns 1778145280056. Format Datetime reads all three and returns one consistent set of date fields. RichAPI runs Format Datetime as a local function, so the call reaches no external provider and the date leaves no trace with a third party. The endpoint tries 33 date patterns in a fixed order. If no pattern matches, and the input holds only digits, the endpoint reads a Unix timestamp.
Which endpoint does Format Datetime use?
Method:
POSTURL:
https://api.richapi.ai/api/v1/format_datetimeAuthentication:
x-api-keyheaderResponse: Synchronous JSON
Credits: 0.5 credits per call
How to send a Format Datetime request
Copy your API key from the RichAPI dashboard.
Set the
dateparameter to the date string or to the Unix timestamp.Set the
formatparameter to the output pattern that you want.To convert the time zone, set
new_timezoneto an IANA time zone name.Send a
POSTrequest tohttps://api.richapi.ai/api/v1/format_datetime.Send the API key in the
x-api-keyheader.Read
formatted_datefrom the response.
CAUTION: Each Format Datetime call costs 0.5 credits. A call that fails to parse the date returns status 200 and still costs 0.5 credits.
cURL
curl -X POST https://api.richapi.ai/api/v1/format_datetime
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"date": "2026-04-11T14:30:00Z",
"format": "%B %d, %Y",
"new_timezone": "America/New_York",
"locale": "en"
}'
Python
import requests
response = requests.post(
"https://api.richapi.ai/api/v1/format_datetime",
headers={"x-api-key": "YOUR_API_KEY"},
json={
"date": "2026-04-11T14:30:00Z",
"format": "%B %d, %Y",
"new_timezone": "America/New_York",
"locale": "en",
},
timeout=60,
)
response.raise_for_status()
print(response.json())
Node.js
const response = await fetch("https://api.richapi.ai/api/v1/format_datetime", {
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
date: "2026-04-11T14:30:00Z",
format: "%B %d, %Y",
new_timezone: "America/New_York",
locale: "en",
}),
});
const data = await response.json();
console.log(data);
Which parameters does Format Datetime accept?
Parameter | Type | Required | Default | Description |
| string | Yes | — | The date string or the Unix timestamp to parse. RichAPI trims the outer spaces. An empty value returns status |
| string | No |
| The output pattern for |
| string | No |
| The IANA time zone of the input, for a value that carries no UTC offset. |
| string | No |
| The IANA time zone for the output. When |
| string | No |
| The language of the month names and the weekday names in the localized fields. Accepted values: |
Only date is required. A request that holds date alone returns every field in UTC and in English.
Which input date formats does Format Datetime accept?
Format Datetime tries these 33 patterns in this order and keeps the first match. If no pattern matches, the endpoint reads the value as a Unix timestamp.
Family | Example input |
ISO 8601 with |
|
ISO 8601 with an offset |
|
ISO 8601 with no zone |
|
Date and time, space separated |
|
Date only |
|
Slash date |
|
Compact digits |
|
US order, month first |
|
European order, day first |
|
Day, month name, year |
|
Month name, day, year |
|
RFC 2822 and RFC 1123 |
|
RFC 822 |
|
ANSIC |
|
Unix date |
|
Ruby date |
|
Unix milliseconds |
|
The month name and the weekday name in the input must be English. Format Datetime parses 11 Apr 2026. It fails to parse 11 avr. 2026.
CAUTION: The US pattern runs before the European pattern. Format Datetime reads 04/11/2026 as April 11, 2026 and 11/04/2026 as November 4, 2026. For a day-first source, convert the value to 2026-04-11 before you send it.
CAUTION: A 10-digit Unix seconds value matches the compact digit pattern first. The result is a date in the year 1775 or another wrong year. Send the timestamp in milliseconds, such as 1775917800000. A seconds value with a decimal point, such as 1775917800.0, also parses correctly.
Which format tokens does Format Datetime support?
Format Datetime passes the format value to the Python strftime function. The table lists every token that the endpoint names, with the Go token that maps to it. The example column shows the output for the input 2026-04-05T09:07:05.250Z with no time zone conversion.
Token | Go token | What it produces | Example |
|
| The four-digit year. |
|
|
| The two-digit year. |
|
|
| The full month name in English. |
|
|
| The short month name in English. |
|
|
| The two-digit month. |
|
|
| The month with no zero prefix. |
|
|
| The two-digit day of the month. |
|
|
| The day with no zero prefix. |
|
|
| The full weekday name in English. |
|
|
| The short weekday name in English. |
|
|
| The two-digit hour on a 24-hour clock. |
|
|
| The two-digit hour on a 12-hour clock. |
|
|
| The 12-hour hour with no zero prefix. |
|
|
| The two-digit minute. |
|
|
| The minute with no zero prefix. |
|
|
| The two-digit second. |
|
|
| The second with no zero prefix. |
|
|
| The meridiem marker, |
|
|
| The microseconds, six digits. |
|
|
| The time zone abbreviation. |
|
|
| The UTC offset. |
|
| — | A literal percent sign. |
|
Any other token that Python strftime supports also works. Every character that is not a token passes through unchanged, so %B %-d, %Y at %-I:%M %p returns April 5, 2026 at 9:07 AM.
CAUTION: The tokens %B, %b, %A, and %a always return English names. The locale parameter changes the localized fields, not formatted_date.
How do I use a Go layout instead?
Format Datetime accepts a Go reference layout in the same format parameter. Six tokens mark a Go layout: 2006, 01, 02, 15, 04, and 05. If the format value holds one of them, RichAPI translates the whole value to strftime tokens first. The Go token column above lists every string that the translation replaces.
{ "date": "2026-04-05T09:07:05Z", "format": "Monday, January 2, 2006 at 3:04 PM" }
The request above returns formatted_date as Sunday, April 5, 2026 at 9:07 AM.
CAUTION: The translation runs on the whole format value. A strftime pattern that also holds 2006, 01, 02, 15, 04, or 05 as literal text gets translated too. Write a literal year as %Y instead of 2026.
How does Format Datetime handle time zones?
Format Datetime applies these five rules in this order.
Case | What Format Datetime does |
The input carries a UTC offset, such as | The endpoint keeps that offset and ignores |
The input carries no offset, or it ends with a literal | The endpoint applies |
| The endpoint uses UTC for the calculation. |
| The endpoint converts every date field to that zone and sets |
| The endpoint keeps the original time zone and returns status |
CAUTION: The applied_timezone field echoes the requested name. It is not proof that the conversion happened. To confirm a conversion, compare full_date_time with the input time.
An input that ends with the literal Z parses as a value with no offset, so original_timezone decides the instant. The default UTC gives the correct result. If you set original_timezone to Europe/Paris for a Z input, the endpoint reads the time as a Paris time.
What does Format Datetime return?
The block below is an example response for the cURL request above. It parses 2026-04-11T14:30:00Z and converts it to America/New_York.
{
"formatted_date": "April 11, 2026",
"localized_short_date": "04/11/2026",
"localized_date_with_month_name": "April 11, 2026",
"localized_date_with_weekday": "Saturday, April 11, 2026",
"full_date_time": "2026-04-11 10:30:00",
"localized_time": "10:30:00 AM",
"localized_date_time": "April 11, 2026 10:30:00 AM",
"month_name": "April",
"time": "10:30:00",
"year": 2026,
"short_year": 26,
"day": 11,
"month_number": 4,
"unix_timestamp": 1775917800,
"original_input": "2026-04-11T14:30:00Z",
"parsed_successfully": true,
"applied_timezone": "America/New_York",
"applied_locale": "en"
}
Which fields does the Format Datetime response hold?
Field | Type | Description |
| string | The date in the pattern that |
| string | The date as |
| string | The month name, the day, and the year, for example |
| string | The same date with the weekday name in front, for example |
| string | The date and the time as |
| string | The time on a 12-hour clock with seconds, for example |
| string | The long date and the 12-hour time, for example |
| string | The full month name in the language that |
| string | The time as |
| integer | The four-digit year, for example |
| integer | The last two digits of the year, for example |
| integer | The day of the month, |
| integer | The month number, |
| integer | The instant as Unix seconds. |
| string | The |
| boolean |
|
| string | The time zone name that RichAPI reports. It holds |
| string | The |
The formatted_date field is the only field that format controls. Every other field uses a fixed pattern.
How do I convert a LinkedIn timestamp into a readable date?
The LinkedIn Company Posts API returns two date values for each post: postedAt.date as 2026-05-07T09:14:40.056Z, and postedAt.timestamp as 1778145280056. Format Datetime reads both and returns the same result.
Send the ISO 8601 value and ask for a readable date in the reader's time zone.
curl -X POST https://api.richapi.ai/api/v1/format_datetime
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"date": "2026-05-07T09:14:40.056Z",
"format": "%B %-d, %Y",
"new_timezone": "America/New_York"
}'
The response holds the readable date in formatted_date.
{
"formatted_date": "May 7, 2026",
"localized_short_date": "05/07/2026",
"localized_date_with_month_name": "May 7, 2026",
"localized_date_with_weekday": "Thursday, May 7, 2026",
"full_date_time": "2026-05-07 05:14:40",
"localized_time": "5:14:40 AM",
"localized_date_time": "May 7, 2026 5:14:40 AM",
"month_name": "May",
"time": "05:14:40",
"year": 2026,
"short_year": 26,
"day": 7,
"month_number": 5,
"unix_timestamp": 1778145280,
"original_input": "2026-05-07T09:14:40.056Z",
"parsed_successfully": true,
"applied_timezone": "America/New_York",
"applied_locale": "en"
}
The millisecond value 1778145280056 returns the same 18 fields. Only original_input differs, because it echoes the value that you sent. Both requests cost 0.5 credits.
To write the date in French, set locale to fr and read localized_date_with_month_name. That field returns mai 7, 2026, while formatted_date stays in English.
What does Format Datetime return for an unparseable date?
Format Datetime returns status 200 with parsed_successfully set to false. Every string field holds an empty string and every numeric field holds 0. The original_input, applied_timezone, and applied_locale fields still echo the request.
{
"parsed_successfully": false,
"original_input": "not a date",
"formatted_date": "",
"localized_short_date": "",
"localized_date_with_month_name": "",
"localized_date_with_weekday": "",
"full_date_time": "",
"localized_time": "",
"localized_date_time": "",
"month_name": "",
"time": "",
"year": 0,
"short_year": 0,
"day": 0,
"month_number": 0,
"unix_timestamp": 0,
"applied_timezone": "UTC",
"applied_locale": "en"
}
CAUTION: A parse failure returns status 200 and costs 0.5 credits. Test parsed_successfully before you write the result to a record.
A request that holds no date field returns status 400 with the message Missing required field: date. A date value of spaces alone returns status 400 with the body {"error": "date is required"}. A 400 response costs no credit.
How much does Format Datetime cost?
Format Datetime costs 0.5 credits per call. At $0.02 a credit, the rate on the 1,000 and 5,000 credit packs, one call costs $0.01. Larger packs cost less per credit. The credit count does not change with the input format, the output format, the time zone, or the locale.
Calls | Credits | Cost |
1 | 0.5 | $0.01 |
100 | 50 | $1.00 |
1,000 | 500 | $10.00 |
10,000 | 5,000 | $100.00 |
Which errors can Format Datetime return?
Status | Meaning | What to do |
| The request body is absent, the body is not valid JSON, or | Send a JSON object that holds a non-empty |
| The API key is missing, wrong or revoked. | Send a valid key in the |
| This API key has no access to this endpoint ( | Call |
| The endpoint name is wrong. | Send the request to |
| The request used a method other than | Send the request as |
| The request rate is over the limit. | Wait, then send the request again. For a higher limit, contact support. |
| The API failed. | Send the request again. If the failure repeats, contact support. |
RichAPI charges no credit for a 400, 401, 403, 404, 405, 429, or 500 response. RichAPI charges 0.5 credits for every 200 response, and a parse failure returns status 200.
Frequently asked questions
Does Format Datetime call an external service?
No. RichAPI runs Format Datetime as a local function inside the API. The date reaches no third-party provider, and the response returns in a few milliseconds.
Does the locale parameter change the formatted_date field?
No. The formatted_date field always uses English month names and English weekday names. The locale parameter changes month_name, localized_date_with_month_name, localized_date_with_weekday, and localized_date_time. The accepted values are en, fr, es, and de.
How does Format Datetime read the date 04/11/2026?
Format Datetime reads it as April 11, 2026, because the US pattern %m/%d/%Y runs before the European pattern %d/%m/%Y. The value 11/04/2026 returns November 4, 2026. For a day-first source, convert the value to 2026-04-11 before you send it.
Does Format Datetime accept a Unix timestamp?
Yes, in milliseconds. Send 1775917800000. A numeric value of 1,000,000,000,000 or more is divided by 1000 and read as milliseconds. A plain 10-digit seconds value matches a compact date pattern first and returns a wrong year. Add a decimal point and send 1775917800.0 instead.
What does Format Datetime do with an unknown new_timezone value?
Format Datetime keeps the original time zone and returns status 200. No error is returned, and applied_timezone holds the original_timezone value. Send an IANA name such as America/New_York or Europe/Berlin.
Can one Format Datetime call format more than one date?
No. Each call reads one date value and costs 0.5 credits. To convert a list of dates, send one call per date.
Which field holds the machine-readable date?
The unix_timestamp field holds the instant as Unix seconds, and full_date_time holds it as YYYY-MM-DD HH:MM:SS. Neither field is affected by the format parameter or by the locale parameter.
