Dates in WordPress are scattered across multiple functions. And while the regular php date functions are pretty good, WordPress one-ups these functions my offering them in multiple languages, so all of Cuisine’s date functions use native WordPress functions, but just structure them a bit better.

The Date class is a Utility which basically means you can address all methods as static functions, without using a wrapper of Facade. To use the Date class, include the class and namespace at the top of your php document:

use Cuisine\Utilities\Date

Getting a date in the language WordPress is set in

To get a date in the format you’d like and in the same language as WordPress is set in, you can just use this:

Date::get( '5-6-2016', 'j F, Y' );

Here’s a break-down: >Date::get() takes a string or timestamp and returns it in the format of your choice.

> >The parameters passed down to the get-function are, in order of appearence: > >* Date (optional) > This can be a string or a timestamp. Defaults to the currents post-date > >* Format (optional) > Use regular WordPress date formats for this. Defaults to ‘j F Y’. >

Relative dates

Relative dates in Cuisine are very easy. All you need is a date and time which you want to get relative.

Date::relative( '5-6-2016' );

The function up above returns a string with relative date.