Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/date

Package Overview
Dependencies
Maintainers
9
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/date

Date module for WordPress.

  • 3.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75K
decreased by-18.46%
Maintainers
9
Weekly downloads
 
Created
Source

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

src/index.js#L323-L327

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|null): Date object or string, parsable by moment.js.

Returns

string: Formatted date.

dateI18n

src/index.js#L356-L366

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

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue (Date|string|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

src/index.js#L282-L311

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|null): Date object or string, parsable by moment.js.

Returns

string: Formatted date.

getDate

src/index.js#L389-L395

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

src/index.js#L339-L342

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|null): Date object or string, parsable by moment.js.

Returns

string: Formatted date.

isInTheFuture

src/index.js#L375-L380

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

src/index.js#L36-L83

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

Parameters

  • dateSettings Object: Settings, including locale data.



Code is Poetry.

Keywords

FAQs

Package last updated on 20 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc