Skip to content

Instantly share code, notes, and snippets.

@tbsmcd
Created July 13, 2012 09:08
Show Gist options
  • Save tbsmcd/3103788 to your computer and use it in GitHub Desktop.
Save tbsmcd/3103788 to your computer and use it in GitHub Desktop.
13fri2
#!/path/to/php
<?php
$week = array(
'Mon' => 0,
'Tue' => 0,
'Wed' => 0,
'Thu' => 0,
'Fri' => 0,
'Sat' => 0,
'Sun' => 0,
);
$period = new DatePeriod(
new Datetime('1983-06-13'),
new DateInterval('P1M'),
new Datetime('2013-05-14')
);
foreach ($period as $day) {
$week[$day->format('D')]++;
}
var_dump($week);
// result
//
// array(7) {
// 'Mon' =>
// int(52)
// 'Tue' =>
// int(52)
// 'Wed' =>
// int(52)
// 'Thu' =>
// int(51)
// 'Fri' =>
// int(51)
// 'Sat' =>
// int(51)
// 'Sun' =>
// int(51)
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment