{"id":13452524,"url":"https://github.com/zapier/intl-dateformat","last_synced_at":"2025-08-16T16:07:58.359Z","repository":{"id":57275461,"uuid":"163204506","full_name":"zapier/intl-dateformat","owner":"zapier","description":"Format a date using Intl.DateTimeFormat goodness.","archived":false,"fork":false,"pushed_at":"2023-09-12T16:21:26.000Z","size":10676,"stargazers_count":61,"open_issues_count":2,"forks_count":8,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-12-11T02:42:17.832Z","etag":null,"topics":["date","format","i18n","intl-dateformat","javascript","l10n","library","module","small","timezone"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapier.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-26T17:53:46.000Z","updated_at":"2024-11-12T19:10:24.000Z","dependencies_parsed_at":"2024-01-16T03:46:25.044Z","dependency_job_id":"5aa20373-45a7-4f02-9e70-81f037d0e73c","html_url":"https://github.com/zapier/intl-dateformat","commit_stats":{"total_commits":39,"total_committers":4,"mean_commits":9.75,"dds":"0.10256410256410253","last_synced_commit":"1da7d7702d43bd4239ebf4eb1e4fa582bbab2624"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fintl-dateformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fintl-dateformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fintl-dateformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fintl-dateformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapier","download_url":"https://codeload.github.com/zapier/intl-dateformat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230367928,"owners_count":18215338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","format","i18n","intl-dateformat","javascript","l10n","library","module","small","timezone"],"created_at":"2024-07-31T07:01:26.554Z","updated_at":"2024-12-19T03:09:47.231Z","avatar_url":"https://github.com/zapier.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg src=\"./art.png\" width=\"600\" height=\"300\" /\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eFormat a date using Intl.DateTimeFormat goodness.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.com/zapier/intl-dateformat\"\u003e\n    \u003cimg src=\"https://flat.badgen.net/travis/zapier/intl-dateformat\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://flat.badgen.net/badgesize/gzip/https://unpkg.com/intl-dateformat@latest/lib/index.js\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#example\"\u003eExample\u003c/a\u003e •\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n\u003c/p\u003e\n\n**intl-dateformat** is a simple date formatting library that leverage the [Intl.DateTimeFormat](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/DateTimeFormat) API to format dates in different languages and timezones without having to clutter your JavaScript bundles.\n\n## Features\n\n- ✌ **Small**: As it directly leverages `Intl.DateTimeFormat`, there is no need to bundle additional locales or a timezones database. It's already in your Browser!\n- 👌**Simple**: It supports a subset of ISO 8601 formats, discarding very rarely used date parts.\n- 🤟 **Extensible**: That said, if you want to customize things you can pass [custom formatters](#custom-formatters).\n\n## Installation\n\n```js\n$ npm install intl-dateformat\n```\n\n## Example\n\n```js\nimport formatDate from 'intl-dateformat'\n\nconst date = new Date(Date.UTC(1984, 0, 17, 16, 13, 37, 0))\n\nformatDate(date, 'YYYY-MM-DD hh:mm:ss A')\n// → 1984-01-17 04:13:37 PM\nformatDate(date, 'YYYY-MM-DD hh:mm:ss A', { timezone: 'Asia/Singapore' })\n// → 1984-01-18 00:13:37 AM\nformatDate(date, 'YYYY, MMMM dddd DD')\n// → 1984, January Tuesday 17\nformatDate(date, '[It is] dddd [today!]')\n// → It is Tuesday today!\nformatDate(date, 'YYYY, MMMM dddd DD', { locale: 'fr' })\n// → 1984, Janvier Mardi 17\n```\n\n## Usage\n\n```js\nimport formatDate from 'intl-dateformat'\n\nconst date = new Date(Date.UTC(1984, 0, 17, 16, 13, 37, 0))\n\nformatDate(date, 'YYYY-MM-DD hh:mm:ss A')\n// → 1984-01-17 04:13:37 PM\n```\n\n| Argument  | Description               | Type                    |\n| --------- | ------------------------- | ----------------------- |\n| `date`    | The date to format        | `Date`, `number`        |\n| `format`  | The format to use         | See [Format](#format)   |\n| `options` | Custom locale or timezone | See [Options](#options) |\n\n### Format\n\nThe format is a combination of the following masks:\n\n| Mask   | Description           | Example    |\n| ------ | --------------------- | ---------- |\n| `YYYY` | 4-digits year         | `1984`     |\n| `YY`   | 2-digits year         | `84`       |\n| `MMMM` | Month name            | `January`  |\n| `MMM`  | Short month name      | `Jan`      |\n| `DD`   | 2-digits day          | `17`       |\n| `dddd` | Day of the week       | `Tuesday`  |\n| `ddd`  | Short day of the week | `Tue`      |\n| `A`    | Day period            | `AM`, `PM` |\n| `a`    | Lowercased day period | `am`, `pm` |\n| `HH`   | 24-hours hour         | `16`       |\n| `hh`   | 12-hours hour         | `04`       |\n| `mm`   | 2-digit minute        | `13`       |\n| `ss`   | 2-digit second        | `37`       |\n\nMasks will be replaced by their associated date part.\n\nYou can also pass string literals in the format by surrouding them with a `[]`:\n\n```js\nformatDate(date, '[It is] dddd [today!]')\n// → It is Tuesday today!\n```\n\n### Options\n\n- `locale` - A [BCP 47](https://tools.ietf.org/html/bcp47) tag to identify the output language\n  - Type: `string`\n  - Default: The system locale\n  - Example: `fr`, `fr-FR`\n- `timezone` - A [IANA timezone](https://www.iana.org/time-zones)\n  - Type: `string`\n  - Default: The system timezone\n  - Example: `Europe/Paris`, `America/Chicago`\n\n## Custom formatters\n\nIf you find yourself missing some date parts, no problem we got you covered. You can create your own `dateFormat` function and add your custom formatters:\n\n```js\nimport { createDateFormatter } from 'intl-dateformat'\n\nconst formatDate = createDateFormatter({\n  // numeric hour\n  h: ({ hour }) =\u003e hour[0] === '0' ? hour[1] : hour\n  // milliseconds\n  SSS: (parts, date) =\u003e String(date.getTime()).slice(-3)\n})\n\nconst date = new Date(Date.UTC(1984, 0, 17, 16, 13, 37, 0))\n\nformatDate(date, 'YYYY-MM-DD h:mm:ss.SSS')\n// → 1984-01-17 4:13:37.505\n```\n\n| Argument     | Description       | Type                          |\n| ------------ | ----------------- | ----------------------------- |\n| `formatters` | Custom formatters | See [Formatters](#formatters) |\n\n### Formatters\n\nFormatters are represented as a dictionary of functions, where the key represents the mask that is to be matched in the `format` and the value is the function that will format the date.\n\nThe formatter function takes the following arguments:\n\n- `parts` - An object containing all the date parts provided by `Intl.DateTimeFormat`. You can inspect the [DatePartName](./src/types.ts) type for an exhaustive list of all the date parts\n- `date` - The original date passed to the `formatDate` function.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fintl-dateformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapier%2Fintl-dateformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fintl-dateformat/lists"}