Created
April 29, 2019 09:32
-
-
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.
This file contains hidden or 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 | |
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