PHP code example of krzysztofzylka / date
1. Go to this page and download the library: Download krzysztofzylka/date 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/ */
krzysztofzylka / date example snippets
$date = new \Krzysztofzylka\Date\Date();
\Krzysztofzylka\Date\Date::create()
\Krzysztofzylka\Date\Date::create(time())
\Krzysztofzylka\Date\Date::create(date('Y-m-d H:i:s'))
\Krzysztofzylka\Date\Date::create(new DateTime())
$date->getTime()
$date->getDate()
$date->getDay()
$date->getMonth()
$date->getYear()
$date->getISO8601()
$date = \Krzysztofzylka\Date\Date::create();
$date2 = \Krzysztofzylka\Date\Date::create($date)->addDay(1);
var_dump($date->getDifference($date2)); //['years' => 0, 'months' => 0, 'days' => 1, 'hours' => 0, 'minutes' => 0, 'seconds' => 0]
$date->getWeekdayDifference($date)
$date->set(null)
$date->set(time())
$date->set(date('Y-m-d H:i:s'))
$date->format($format)
$date->addSecond($seconds)
$date->addMinute($minutes)
$date->addHour($hours)
$date->addDay($days)
$date->addWeek($weeks)
$date->addMonth($months, $fixCalculate)
$date = new \Krzysztofzylka\Date\Date('2024-03-31');
$date->addMonth(1);
echo $date->getDate('Y-m-d'); //2024-04-30
$date = new \Krzysztofzylka\Date\Date('2024-03-31', false);
$date->addMonth(1);
echo $date->getDate('Y-m-d'); //2024-05-01
$date->addYear($years)
$date->subSecond($seconds)
$date->subMinute($minutes)
$date->subHour($hours)
$date->subDay($days)
$date->subWeek($weeks)
$date->subMonth($months)
$date->subYear($years)
$date->isBefore($date)
$date->isAfter($date)
$date->isEqual($date)
$date->startOfDay()
$date->endOfDay()
$date->isWeekend()
$date->isWeekday()
$date->isLeapYear()
\Krzysztofzylka\Date\DateUtils::dateMonthDifference($dateFrom, $dateTo)
\Krzysztofzylka\Date\DateUtils::getSimpleDate()
\Krzysztofzylka\Date\DateUtils::getSimpleDate(true) //with microseconds
\Krzysztofzylka\Date\DateUtils::getSecondsToDate($seconds)
$date = \Krzysztofzylka\Date\Date::create();
$date2 = \Krzysztofzylka\Date\Date::create($date)->addDay(1);
var_dump(\Krzysztofzylka\Date\DateUtils::getDifference($date, $date2)); //['years' => 0, 'months' => 0, 'days' => 1, 'hours' => 0, 'minutes' => 0, 'seconds' => 0]