PHP code example of ricardokovalski / holidays

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

    

ricardokovalski / holidays example snippets


use Holidays\Collections\AllHolidays;

$collection = new AllHolidays();
$collection->getCollection();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$collection->orderByTimestamp()
    ->ascending()
    ->getCollection();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$collection->orderByTimestamp()
    ->ascending()
    ->first();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$collection->orderByTimestamp()
    ->ascending()
    ->last();

use Holidays\Collections\NationalHolidays;

$startDate = \DateTime::createFromFormat('d/m/Y', '01/01/2020');
$endDate = \DateTime::createFromFormat('d/m/Y', '30/06/2020');

$collection = new NationalHolidays();
$collection->between($startDate, $endDate)
    ->orderByTimestamp()
    ->ascending()
    ->getCollection();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays(2021);
$collection->orderByTimestamp()
    ->ascending()
    ->getCollection();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$holiday = $collection->orderByTimestamp()
    ->ascending()
    ->first();    
    
$holiday->formatter('d/m/Y');

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$holiday = $collection->orderByTimestamp()
    ->ascending()
    ->first();    
    
$holiday->next();

use Holidays\Collections\NationalHolidays;

$collection = new NationalHolidays();
$holiday = $collection->orderByTimestamp()
    ->ascending()
    ->first();    
    
$holiday->previous();