# @wordpress/date

> Date module for WordPress.

Latest version **5.55.0** (published 2026-09-10) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/date
pnpm add @wordpress/date
yarn add @wordpress/date
bun add @wordpress/date
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.55.0 |
| Published | 2026-09-10 |
| First published | 2018-05-30 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 3 |
| Unpacked size | 166.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11754 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, gutenberg, date |

## Links

- npm: https://www.npmjs.com/package/@wordpress/date
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/date/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/date

## Dependencies (3)

- [moment](https://npm.io/package/moment.md) ^2.29.4
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.40
- [@wordpress/deprecated](https://npm.io/package/@wordpress/deprecated.md) ^4.55.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 5.55.0 (latest) — 2026-09-10
- 5.54.1-next.v.202609031004.0 (next) — 2026-09-03
- 5.40.1 (wp-7.0) — 2026-06-30
- 5.33.1 (wp-6.9) — 2025-10-28
- 5.19.1 (wp-6.8) — 2025-03-10
- 5.8.2 (wp-6.7) — 2024-09-30
- 5.0.1 (wp-6.6) — 2024-06-11
- 4.51.1 (wp-6.5) — 2024-02-20
- 4.42.13 (wp-6.4) — 2023-11-13
- 4.35.2 (wp-6.3) — 2023-10-12
- 4.26.3 (wp-6.2) — 2023-10-12
- 4.17.1 (wp-6.1) — 2022-09-20
- 4.6.1 (wp-6.0) — 2022-04-19
- 4.2.3 (wp-5.9) — 2021-11-15
- 4.1.2 (wp-5.8) — 2021-09-01
- … 241 more at https://npm.io/package/@wordpress/date/versions

## README

# Date

Date module for WordPress.

## Installation

Install the module

```bash
npm install @wordpress/date --save
```

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### date

Formats a date (like `date()` in PHP).

_Related_

-   <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
-   <https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC>

_Parameters_

-   _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
-   _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
-   _timezone_ `string`: Timezone to output result in or a UTC offset. Defaults to timezone from site.

_Returns_

-   `string`: Formatted date in English.

### dateI18n

Formats a date (like `wp_date()` in PHP), translating it into site's locale.

Backward Compatibility Notice: if `timezone` is set to `true`, the function behaves like `gmdateI18n`.

_Related_

-   <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
-   <https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC>

_Parameters_

-   _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
-   _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
-   _timezone_ `string | number | boolean`: Timezone to output result in or a UTC offset. Defaults to timezone from site. Notice: `boolean` is effectively deprecated, but still supported for backward compatibility reasons.

_Returns_

-   Formatted date.

### format

Formats a date. Does not alter the date's timezone.

_Parameters_

-   _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
-   _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.

_Returns_

-   Formatted date.

### getDate

Create and return a JavaScript Date Object from a date string in the WP timezone.

_Parameters_

-   _dateString_ `string | null`: Date formatted in the WP timezone.

_Returns_

-   Date

### getSettings

Returns the currently defined date settings.

_Returns_

-   `DateSettings`: Settings, including locale data.

### gmdate

Formats a date (like `date()` in PHP), in the UTC timezone.

_Parameters_

-   _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
-   _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.

_Returns_

-   Formatted date in English.

### gmdateI18n

Formats a date (like `wp_date()` in PHP), translating it into site's locale and using the UTC timezone.

_Parameters_

-   _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
-   _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.

_Returns_

-   Formatted date.

### humanTimeDiff

Returns a human-readable time difference between two dates, like human_time_diff() in PHP.

_Parameters_

-   _from_ `Moment | Date | string | number`: From date, in the WP timezone.
-   _to_ `Moment | Date | string | number`: To date, formatted in the WP timezone.

_Returns_

-   Human-readable time difference.

### isInTheFuture

Check whether a date is considered in the future according to the WordPress settings.

_Parameters_

-   _dateValue_ `Date | string | number`: Date String or Date object in the Defined WP Timezone.

_Returns_

-   Is in the future.

### setSettings

Adds a locale to moment, using the format supplied by `wp_localize_script()`.

_Parameters_

-   _dateSettings_ `DateSettings`: Settings, including locale data.

<!-- END TOKEN(Autogenerated API docs) -->

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

---
_Source: https://npm.io/package/@wordpress/date · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
