PHP code example of irfa / php-hari-libur

1. Go to this page and download the library: Download irfa/php-hari-libur 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/ */

    

irfa / php-hari-libur example snippets


'providers' => [
    ....
    Irfa\HariLibur\HariLiburServiceProvider::class,
     ];

'aliases' => [
         ....
        'HariLibur' => Irfa\HariLibur\Facades\HariLibur::class,

    ],

config/irfa/hari_libur.php

use Irfa\HariLibur\Facades\HariLibur;
atau
use HariLibur;

use Irfa\HariLibur\Func\HariLibur;
....
$libur = new HariLibur();
var_dump($libur->date("17-08-2021")->isHoliday());

HariLibur::date("17-08-2021")->isHoliday();
//return true

if(HariLibur::date("17-08-2021")->isHoliday())
{
    echo "Waktunya liburan.";
} else {
    echo "Waktunya bekerja.";
}

HariLibur::date("17-03-2021")->isWeekend();
//return false

if(HariLibur::date("17-08-2021")->isWeekend())
{
    echo "Selamat berakhir pekan.";
} else {
    echo "Waktunya bekerja.";
}

HariLibur::date("17-08-2021")->isDayOff();
//return true

HariLibur::date("17-08-2021")->nextHoliday(); 
// mengambil data hari libur setelah tanggal 17-03-2021
HariLibur::date("17-08-2021")->prevHoliday(); 
// mengambil data hari libur setelah tanggal 17-03-2021

$date = HariLibur::date("17-08-2021");
//mengambil data hari libur sebelum tangal 17-08-2021
foreach ($date->nextHoliday() as $hariLibur) {
    echo "Tanggal: ".$hariLibur->date." Deskripsi: ".$hariLibur->description."<br>";
  }
//mengambil data hari libur sesudah tangal 17-08-2021
foreach ($date->prevHoliday() as $hariLibur) {
    echo "Tanggal: ".$hariLibur->date." Deskripsi: ".$hariLibur->description."<br>";
  }

HariLibur::get();

foreach (HariLibur::get() as $hariLibur) {
		echo "Tanggal: ".$hariLibur->date." Deskripsi: ".$hariLibur->description."<br>";
	}

HariLibur::date("17-08-2021")->getInfo();
//return Hari Kemerdekaan Republik Indonesia

HariLibur::regional("ID")->get();

composer remove irfa/php-hari-libur

composer update irfa/php-hari-libur

/vendor/irfa/php-hari-libur/config/hari_libur.php