Skip to content

Instantly share code, notes, and snippets.

@mikkame
Created December 19, 2019 08:20
Show Gist options
  • Save mikkame/334ce035b16c7ddb96c7947e3539efd4 to your computer and use it in GitHub Desktop.
Save mikkame/334ce035b16c7ddb96c7947e3539efd4 to your computer and use it in GitHub Desktop.
laravel de calender
function calendar()
{
$cal = [];
foreach (range(0, 6) as $add) {
$m = Carbon::parse(date('Y-m-01'))->addMonth($add);
$ym = $m->format('Y年m月');
foreach (range(0, $m->format('t')-1) as $addd) {
$date = $m->copy()->addDay($addd);
$w = $date->format('w');
$W = $date->format('W');
if ($w == 0) {
$W++;
}
$cal[$ym][$W][$w] = [$date->format('Y-n-d'), $date->format('j')];
}
}
return $cal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment