---
title: "Format dates and numbers for the reader · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/languages-and-regions/locale-content
updated: 2026-10-20
licence: "All rights reserved"
---

# Format dates and numbers for the reader

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Languages and regions](https://agentwranglers.se/playbook/website/languages-and-regions)
- Rule: Format dates, numbers and money for the reader's locale with a formatting library. Show times with a named time zone.
- How: Format with an ICU-based library, such as `Intl` in JavaScript, Babel in Python, the intl extension in PHP or ICU4J in Java. Always pass a locale, and pass a time zone for dates and times. Store and send moments in UTC, as in [dates and times](https://agentwranglers.se/playbook/api-design/requests-and-responses/dates-and-times), and convert only for display.
- Check: A unit test formats a fixed date and amount for each supported locale. The output matches the expected strings.

Example:

```js
const when = new Date('2026-03-05T14:00:00Z');
new Intl.DateTimeFormat('sv-SE', { dateStyle: 'long', timeStyle: 'long', timeZone: 'Europe/Stockholm' }).format(when);
// "5 mars 2026 kl. 15:00:00 CET"
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(1234.5);
// "1.234,50 €", with a no-break space before the €
```

```python
# Python with Babel
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
from babel.dates import format_datetime
from babel.numbers import format_currency
when = datetime(2026, 3, 5, 14, 0, tzinfo=timezone.utc)
format_datetime(when, "long", tzinfo=ZoneInfo("Europe/Stockholm"), locale="sv_SE")
# "5 mars 2026 15:00:00 CET"
format_currency(1234.5, "EUR", locale="de_DE")  # "1.234,50 €"
```

```php
// PHP with the intl extension
$when = new DateTimeImmutable('2026-03-05T14:00:00Z');
$dates = new IntlDateFormatter('sv_SE', IntlDateFormatter::LONG, IntlDateFormatter::LONG, 'Europe/Stockholm');
echo $dates->format($when); // "5 mars 2026 kl. 15:00:00 CET"
echo (new NumberFormatter('de_DE', NumberFormatter::CURRENCY))->formatCurrency(1234.5, 'EUR'); // "1.234,50 €"
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/languages-and-regions/locale-content`.

- Previous: [Support vertical and CJK text](https://agentwranglers.se/playbook/website/languages-and-regions/writing-modes)
- Next: [Get plurals right in every language](https://agentwranglers.se/playbook/website/languages-and-regions/plural-rules)
- [Languages and regions](https://agentwranglers.se/playbook/website/languages-and-regions)
