Skip to main content

Format Datetime API

Written by Kadri - RichAPI Support Team

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: POST

  • URL: https://api.richapi.ai/api/v1/format_datetime

  • Authentication: x-api-key header

  • Response: Synchronous JSON

  • Credits: 0.5 credits per call

How to send a Format Datetime request

  1. Copy your API key from the RichAPI dashboard.

  2. Set the date parameter to the date string or to the Unix timestamp.

  3. Set the format parameter to the output pattern that you want.

  4. To convert the time zone, set new_timezone to an IANA time zone name.

  5. Send a POST request to https://api.richapi.ai/api/v1/format_datetime.

  6. Send the API key in the x-api-key header.

  7. Read formatted_date from 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

date

string

Yes

—

The date string or the Unix timestamp to parse. RichAPI trims the outer spaces. An empty value returns status 400.

format

string

No

""

The output pattern for formatted_date. Accepts Python strftime tokens or a Go layout. When format is empty, formatted_date uses the pattern %Y-%m-%d %H:%M:%S.

original_timezone

string

No

UTC

The IANA time zone of the input, for a value that carries no UTC offset.

new_timezone

string

No

""

The IANA time zone for the output. When new_timezone is empty, RichAPI keeps the original time zone.

locale

string

No

en

The language of the month names and the weekday names in the localized fields. Accepted values: en, fr, es, de.

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 Z

2026-04-11T14:30:00Z, 2026-04-11T14:30:00.056Z

ISO 8601 with an offset

2026-04-11T14:30:00+02:00, 2026-04-11T14:30:00.056+0200

ISO 8601 with no zone

2026-04-11T14:30:00, 2026-04-11T14:30:00.056

Date and time, space separated

2026-04-11 14:30:00, 2026-04-11 14:30

Date only

2026-04-11

Slash date

2026/04/11 14:30:00, 2026/04/11

Compact digits

20260411, 20260411143000

US order, month first

04/11/2026 14:30:00, 04/11/2026 14:30, 04/11/2026

European order, day first

11/04/2026 14:30:00, 11/04/2026, 11-04-2026 14:30:00, 11-04-2026

Day, month name, year

11-Apr-2026, 11-April-2026, 11 Apr 2026, 11 April 2026

Month name, day, year

April 11, 2026, Apr 11, 2026

RFC 2822 and RFC 1123

Sat, 11 Apr 2026 14:30:00 +0000, Sat, 11 Apr 2026 14:30:00 UTC

RFC 822

11 Apr 26 14:30 UTC, 11 Apr 26 14:30 +0000

ANSIC

Sat Apr 11 14:30:00 2026

Unix date

Sat Apr 11 14:30:00 UTC 2026

Ruby date

Sat Apr 11 14:30:00 -0700 2026

Unix milliseconds

1775917800000

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

%Y

2006

The four-digit year.

2026

%y

06

The two-digit year.

26

%B

January

The full month name in English.

April

%b

Jan

The short month name in English.

Apr

%m

01

The two-digit month.

04

%-m

1

The month with no zero prefix.

4

%d

02

The two-digit day of the month.

05

%-d

2

The day with no zero prefix.

5

%A

Monday

The full weekday name in English.

Sunday

%a

Mon

The short weekday name in English.

Sun

%H

15

The two-digit hour on a 24-hour clock.

09

%I

03

The two-digit hour on a 12-hour clock.

09

%-I

3

The 12-hour hour with no zero prefix.

9

%M

04

The two-digit minute.

07

%-M

4

The minute with no zero prefix.

7

%S

05

The two-digit second.

05

%-S

5

The second with no zero prefix.

5

%p

PM

The meridiem marker, AM or PM.

AM

%f

.000 or .999

The microseconds, six digits.

250000

%Z

MST

The time zone abbreviation.

UTC

%z

-0700

The UTC offset.

+0000

%%

—

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 +02:00 or -0700.

The endpoint keeps that offset and ignores original_timezone.

The input carries no offset, or it ends with a literal Z.

The endpoint applies original_timezone. The default is UTC.

original_timezone names a zone that does not exist.

The endpoint uses UTC for the calculation. applied_timezone still echoes the name that you sent.

new_timezone names a valid IANA zone.

The endpoint converts every date field to that zone and sets applied_timezone to that name.

new_timezone names a zone that does not exist.

The endpoint keeps the original time zone and returns status 200. No error is returned.

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

formatted_date

string

The date in the pattern that format names. When format is empty, the value uses %Y-%m-%d %H:%M:%S.

localized_short_date

string

The date as MM/DD/YYYY. The order is month first for every locale.

localized_date_with_month_name

string

The month name, the day, and the year, for example April 11, 2026. The month name uses locale.

localized_date_with_weekday

string

The same date with the weekday name in front, for example Saturday, April 11, 2026. The names use locale.

full_date_time

string

The date and the time as YYYY-MM-DD HH:MM:SS. The value carries no time zone marker.

localized_time

string

The time on a 12-hour clock with seconds, for example 10:30:00 AM.

localized_date_time

string

The long date and the 12-hour time, for example April 11, 2026 10:30:00 AM. The month name uses locale.

month_name

string

The full month name in the language that locale names.

time

string

The time as HH:MM:SS on a 24-hour clock.

year

integer

The four-digit year, for example 2026.

short_year

integer

The last two digits of the year, for example 26.

day

integer

The day of the month, 1 to 31.

month_number

integer

The month number, 1 to 12.

unix_timestamp

integer

The instant as Unix seconds.

original_input

string

The date value that you sent, after RichAPI trims the outer spaces.

parsed_successfully

boolean

true after a successful parse. false after a failed parse.

applied_timezone

string

The time zone name that RichAPI reports. It holds new_timezone after a successful conversion, and original_timezone in every other case.

applied_locale

string

The locale value in lower case. RichAPI echoes an unknown value and uses en for the names.

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

400

The request body is absent, the body is not valid JSON, or date is empty.

Send a JSON object that holds a non-empty date value.

401

The API key is missing, wrong or revoked.

Send a valid key in the x-api-key header.

403

This API key has no access to this endpoint (Endpoint not available on your plan).

Call GET /api/v1/my-endpoints to see the endpoints that this key can use. Contact support for access.

404

The endpoint name is wrong.

Send the request to /format_datetime.

405

The request used a method other than POST.

Send the request as POST.

429

The request rate is over the limit.

Wait, then send the request again. For a higher limit, contact support.

500

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.

Related articles

Did this answer your question?