PHP code example of matheus-rosa / php-calendar
1. Go to this page and download the library: Download matheus-rosa/php-calendar 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/ */
matheus-rosa / php-calendar example snippets
use Calendar\App\Calendar;
// Returns a DateTime instance.
var_dump(Calendar::today());
var_dump(Calendar::tomorrow());
var_dump(Calendar::yesterday());
// Get the next day of week based in current date
var_dump(Calendar::now()->nextMonday());
var_dump(Calendar::now()->nextWednesday());
// Returns an array of DateTime objects
$onlyFridays = Calendar::interval('2020-01-01', '2020-03-31')
->onlyFridays();
$onlyTuesdays = Calendar::interval('2020-01-01', '2020-03-31')
->onlyTuesdays();
var_dump($onlyFridays, $onlyTuesdays);
// You can also compute the next/before days from now
Calendar::now()->nextDays(15);
Calendar::now()->beforeDays(15);
// Or specifying a base date
Calendar::fromDate('2020-04-25')->nextDays(15);
Calendar::fromDate('2020-04-25')->beforeDays(15);
// Or even set a specific timezone before handle its operations
Calendar::setTimezone('America/Sao_Paulo');