Skip to content

Instantly share code, notes, and snippets.

@SimonDevelop
Created April 29, 2019 09:32
Show Gist options
  • Save SimonDevelop/c47fe08396c4401ee7ab269f7c945b7d to your computer and use it in GitHub Desktop.
Save SimonDevelop/c47fe08396c4401ee7ab269f7c945b7d to your computer and use it in GitHub Desktop.
Function to retrieve the days of the month of a given date. the table contains the number of the day in index and the day of the week in value.
<?php
function getDays($month = null, $year = null) {
$list = array();
if ($month == null) {
$month = date('m');
}
if ($year == null) {
$year = date('Y');
}
for ($d = 1; $d <= 31; $d++) {
$time = mktime(12, 0, 0, $month, $d, $year);
if (date('m', $time) == $month) {
$list[date('d', $time)] = date('D', $time);
}
}
return $list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment