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::getSimpleDate()
\Krzysztofzylka\Date\Date::getSimpleDate(true) //with microseconds

\Krzysztofzylka\Date\Date::getSecondsToDate($seconds)

\Krzysztofzylka\Date\Date::create(null)
\Krzysztofzylka\Date\Date::create(time())
\Krzysztofzylka\Date\Date::create(date('Y-m-d H:i:s'))

$date->getTime()

$date->getDate()

$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->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->subMonth($months)

$date->subYear($years)

\Krzysztofzylka\Date\DateUtils::dateMonthDifference($dateFrom, $dateTo)