Last active
June 8, 2024 14:06
-
-
Save guangrei/a684e4afb28d67a3b5fc66da055b7ef6 to your computer and use it in GitHub Desktop.
[PHP] pengecekan tanggal merah berdasarkan hari libur nasional dan hari minggu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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/APIHariLibur_V2/main/calendar.json"),true); | |
//check tanggal merah berdasarkan libur nasional | |
if(isset($array[$value]) && $array[$value]["holiday"]) | |
: echo"tanggal merah\n"; | |
print_r($array[$value]); | |
//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("Y-m-d"); | |
echo"<b>Check untuk hari ini (".date("d-m-Y",strtotime($hari_ini)).")</b><br>"; | |
tanggalMerah($hari_ini); |
info: saya sudah merilis api baru yang lebih akurat dan efisien https://github.com/guangrei/APIHariLibur_V2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Myrel666 bisa tapi disarankan menggunakan library phptanggalmerah https://github.com/guangrei/phptanggalmerah