Skip to content

Instantly share code, notes, and snippets.

@paulofreitas
Last active March 19, 2016 13:47
Show Gist options
  • Save paulofreitas/2923df749a75e7e515de to your computer and use it in GitHub Desktop.
Save paulofreitas/2923df749a75e7e515de to your computer and use it in GitHub Desktop.
<?php
use Carbon\Carbon;
class DateUtils extends Carbon
{
public function isSameWeek(Carbon $dt)
{
return $this->weekOfYear === $dt->weekOfYear;
}
}
/*
* $date = DateUtils::parse('2016-03-18');
* if ($date->isSameWeek(DateUtils::today())) { ... }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment