stellarwp/dates

Date utilities and classes.

1.1.3 2024-09-11 17:26 UTC

This package is auto-updated.

Last update: 2024-10-11 17:44:38 UTC


README

Tests Static Analysis

A collection of date utilities authored by the development team at StellarWP and provided free for the WordPress community.

This work is forked from the battle-tested date handling done at The Events Calendar!

Installation

It's recommended that you install Dates as a project dependency via Composer:

composer require stellarwp/dates

We actually recommend that this library gets included in your project using Strauss.

Luckily, adding Strauss to your composer.json is only slightly more complicated than adding a typical dependency, so checkout our strauss docs.

Documentation

How dates are built

The Dates::get() method accepts a number of parameters (a date, a timezone, a fallback date, and an immutable flag). However, you can get the current datetime with a simple call to Dates::get() like so:

use StellarWP\Dates\Dates;

$date = Dates::get();

Whether you are using that simple approach or something more complex, here's what is happening under the hood:

Constants