Skip to content

Instantly share code, notes, and snippets.

@aditnanda
Created May 17, 2022 12:59
Show Gist options
  • Select an option

  • Save aditnanda/43622098c07a657c0533a8eb45ee0277 to your computer and use it in GitHub Desktop.

Select an option

Save aditnanda/43622098c07a657c0533a8eb45ee0277 to your computer and use it in GitHub Desktop.
1. Untuk menghitung hari senin dalam 1 bulan
function total_sun($month,$year)
{
$sundays=0;
$total_days=cal_days_in_month(CAL_GREGORIAN, $month, $year);
for($i=1;$i<=$total_days;$i++)
if(date('N',strtotime($year.'-'.$month.'-'.$i))==7)
$sundays++;
return $sundays;
}
echo total_sun(11,2016);
2. Untuk menghitung banyak hari dalam 1 bulan
$tahun = 2022;
$bulan = 02;
$last_date = date('t', strtotime($tahun.'-'.$bulan.'-01'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment