JSPM

@wordpress/date

3.6.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 86402
  • Score
    100M100P100Q154989F
  • License GPL-2.0-or-later

Date module for WordPress.

Package Exports

  • @wordpress/date

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wordpress/date) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Date

Date module for WordPress.

Installation

Install the module

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 ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.

API

# date

Formats a date (like date() in PHP), in the site's timezone.

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue (Date|string|moment.Moment|null): Date object or string, parsable by moment.js.

Returns

  • string: Formatted date.

# dateI18n

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

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue (Date|string|moment.Moment|null): Date object or string, parsable by moment.js.
  • gmt boolean: True for GMT/UTC, false for site's timezone.

Returns

  • string: Formatted date.

# format

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

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue (Date|string|moment.Moment|null): Date object or string, parsable by moment.js.

Returns

  • string: Formatted date.

# getDate

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

Parameters

  • dateString ?string: Date formatted in the WP timezone.

Returns

  • Date: Date

# gmdate

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

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue (Date|string|moment.Moment|null): Date object or string, parsable by moment.js.

Returns

  • string: Formatted date.

# isInTheFuture

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

Parameters

  • dateValue string: Date String or Date object in the Defined WP Timezone.

Returns

  • boolean: Is in the future.

# setSettings

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

Parameters

  • dateSettings Object: Settings, including locale data.



Code is Poetry.