Skip to content

Instantly share code, notes, and snippets.

@tbsmcd
Created July 13, 2012 09:03
Show Gist options
  • Save tbsmcd/3103771 to your computer and use it in GitHub Desktop.
Save tbsmcd/3103771 to your computer and use it in GitHub Desktop.
13friday
#!/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('2001-01-13'), // 開始日時
new DateInterval('P1M'), // インターバル
new Datetime('2400-12-14') // 終了日時
);
foreach ($period as $day) {
$week[$day->format('D')]++;
}
var_dump($week);
// result
//
// array(7) {
// 'Mon' =>
// int(685)
// 'Tue' =>
// int(685)
// 'Wed' =>
// int(687)
// 'Thu' =>
// int(684)
// 'Fri' =>
// int(688)
// 'Sat' =>
// int(684)
// 'Sun' =>
// int(687)
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment