Menu

Leaf Dates
Handling Dates with Leaf Custom Dates

Overview

Using Leaf Dates

Just like all of Leaf's other functionality, the dates module will also have to be imported

$date = new Leaf\Core\CustomDate();
After this, all the CustomDate methods will be available to us:

CustomDate Function

Basically, CustomDate just gives you methods to manipulate the date and time, faster that DateTime() would allow. Let's take a look at these methods.

Timestamp

Timestamp as the name implies, generates a new random timestamp.

$timestamp = $date->Timestamp();

GetDateFromTimeStamp

This method gets the date in YYYY-MM-DD format from an existing timestamp

$parsedDate = $date->GetDateFromTimeStamp($timestamp);

GetMonthFromNumber

This gets the month in words from a number (0-11)

$month = $date->GetMonthFromNumber($number);

GetDayFromNumber

This gets the day in words from a number (1-7)

$month = $date->GetDayFromNumber($number);

GetEnglishDateFromTimeStamp

This gets the date in the format (MM DD, YYYY) from an existing timestamp

$parsedDate = $date->GetEnglishDateFromTimeStamp($timestamp);

GetEnglishTimeStampFromTimeStamp

This gets the date in the format (DD MM, YYYY HH:MM:SS) from a timestamp

$parsedDate = $date->GetEnglishTimeStampFromTimeStamp($timestamp);

GetTimeFromTimeStamp

This gets the time in the format (HH:MM:SS) from a timestamp

$parsedDate = $date->GetTimeFromTimeStamp($timestamp);

Next Steps

Re-routing to index.php
Simple Routing
Request
Response