Skip to content

Instantly share code, notes, and snippets.

@homleen
Created July 27, 2013 09:25
Show Gist options
  • Save homleen/6094374 to your computer and use it in GitHub Desktop.
Save homleen/6094374 to your computer and use it in GitHub Desktop.
获取当前月的所有日期
$start = new \DateTime('first day of this month');
$end = new \DateTime('first day of this month + 1 month');
$period = new \DatePeriod($start, new \DateInterval('P1D'), $end);
foreach($period as $day){
// here check if you have records with this date and print them,
// otherwise print default values
print $day->format('d.m.Y') . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment