1. Go to this page and download the library: Download madbyad/mpl-date-time library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
madbyad / mpl-date-time example snippets
// This class will store the current date
new Date;
// This class will store the beggining of the unix timestamp "1 January 1970"
new Date(0);
// This class will store 1 day after the beggining of the unix timestamp "2 January 1970"
new Date(86400);
// This class will store the current date
new Date(0, true);
// This class will store the date tommorow
new Date(86400, true);
// This class will store the date yesterday
new Date(-86400, true);
$date = new Date(0);
// this will return "1/1/1970"
echo $date->get(DateFormat::D_M_YYYY);
// this will return "01/01/1970"
echo $date->get(DateFormat::DD_MM_YYYY);
// this will return "Thurday 1 January 1970 01:00"
echo $date->get(DateFormat::DAY_MONTH_YYYY__HOUR_MIN);
// this will return "1/1/1970"
echo $date->get(DateFormat::M_D_YYYY);
// this will return "01/01/1970"
echo $date->get(DateFormat::MM_DD_YYYY);
// this will return "January Thurday 1 1970 01:00"
echo $date->get(DateFormat::MONTH_DAY_YYYY__HOUR_MIN);
// this will return "1970/1/1"
echo $date->get(DateFormat::YYYY_M_D);
// this will return "1970/01/01"
echo $date->get(DateFormat::YYYY_MM_DD);
// this will return "1970 January Thurday 1 01:00"
echo $date->get(DateFormat::YYYY_MONTH_DAY__HOUR_MIN);
// Create a new class that store 0 time (0 second)
new Time();
// Create a new class that store 1 day
new Time(86400);
// Create a new class that store 1 month (30 days)
new Time(86400 * 30);
$time = new Time();
// set the time to be 86400 second of unix timestamp (1 day)
$time->setUnix(86400);
// set the time to be 1 year
$time->setYear(1);
// set the time to be 1 month
$time->setMonth(1);
// set the time to be 1 day
$time->setDay(1);
// set the time to be 1 hour
$time->setHour(1);
// set the time to be 1 minute
$time->setMinute(1);
// set the time to be 1 second
$time->setSecond(1);
$time = new Time();
// add 86400 second of unix timestamp (1 day)
$time->addUnix(86400);
// add 1 year
$time->addYear(1);
// add 1 month
$time->addMonth(1);
// add 1 day
$time->addDay(1);
// add 1 hour
$time->addHour(1);
// add 1 minute
$time->addMinute(1);
// add a second
$time->addSecond(1);
$time = new Time();
// subtract 86400 second of unix timestamp (1 day)
$time->subtractUnix(86400);
// subtract 1 year
$time->subtractYear(1);
// subtract 1 month
$time->subtractMonth(1);
// subtract 1 day
$time->subtractDay(1);
// subtract 1 hour
$time->subtractHour(1);
// subtract 1 minute
$time->subtractMinute(1);
// subtract a second
$time->subtractSecond(1);
// get the unix timestamp
$time->getUnix(86400);
// get the time year
$time->getYear(1);
// get the time month
$time->getMonth(1);
// get the time day
$time->getDay(1);
// get the time hour
$time->getHour(1);
// get the time minute
$time->getMinute(1);
// get the time second
$time->getSecond(1);