Dates A simple library for working with dates and ranges using the default timezone

Getting Started

Usage

Ranges

Setup

All classes are in the duncan3dc\Dates namespace.

The DateTime class is the main class within the library. It is created using a unix timestamp:

$date = new DateTime($row["date_created"]);

Or there is a static method to create an instance using mktime():

$date = DateTime::mktime($hour, $minute, $second, $month, $day, $year);

There is also a Date class which is created using a unix timestamp too, but the time element is ignored, and will always be mid-day.

$date = new Date($row["date_created"]);

There is also a static method similar to mktime()

$date = Date::mkdate($year, $month, $day);



Current date/time

Each class has a helper method to get an instance based on the current date:

$date = Date::now();
$date = DateTime::now();