PHP code example of sunfoxcz / date-utils

1. Go to this page and download the library: Download sunfoxcz/date-utils 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/ */

    

sunfoxcz / date-utils example snippets


 declare(strict_types=1);

use Sunfox\DateUtils\DateTime;
use Sunfox\DateUtils\DateIntervalFactory;

$start = new DateTime('2015-01-01');
$end = new DateTime('2015-12-31');

$months = DateIntervalFactory::create($start, $end, DateIntervalFactory::MONTH, 1, [
	'incomes' => [],
	'expenses' => [],
]);

foreach ($months as $k => $month) {
	echo "{$k}: " . $month->date->format('Y-m-d') . PHP_EOL;
}

 declare(strict_types=1);

use Sunfox\DateUtils\SpentTime;

$spentTime = new SpentTime('1h30m');

echo (string) $spentTime; // 01:30:00
echo $spentTime->getTotalHours(); // 1,5
echo $spentTime->getTotalMinutes(); // 90
echo $spentTime->getTotalSeconds(); // 5400