Skip to content

Instantly share code, notes, and snippets.

@msramdan
Forked from guangrei/script.php
Created January 30, 2021 18:42
Show Gist options
  • Save msramdan/804aa1cee2417d046bdcbd1510e1ee34 to your computer and use it in GitHub Desktop.
Save msramdan/804aa1cee2417d046bdcbd1510e1ee34 to your computer and use it in GitHub Desktop.
[PHP] pengecekan tanggal merah berdasarkan hari libur nasional dan hari minggu
<?php
//default time zone
date_default_timezone_set("Asia/Jakarta");
//fungsi check tanggal merah
function tanggalMerah($value) {
$array = json_decode(file_get_contents("https://raw.githubusercontent.com/guangrei/Json-Indonesia-holidays/master/calendar.json"),true);
//check tanggal merah berdasarkan libur nasional
if(isset($array[$value]))
: echo"tanggal merah ".$array[$value]["deskripsi"];
//check tanggal merah berdasarkan hari minggu
elseif(
date("D",strtotime($value))==="Sun")
: echo"tanggal merah hari minggu";
//bukan tanggal merah
else
:echo"bukan tanggal merah";
endif;
}
//testing
$hari_ini = date("Ymd");
echo"<b>Check untuk hari ini (".date("d-m-Y",strtotime($hari_ini)).")</b><br>";
tanggalMerah($hari_ini);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment