-
-
Save msramdan/804aa1cee2417d046bdcbd1510e1ee34 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/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