ExpressiveDate::startOfWeek PHP Method

startOfWeek() public method

Use the start of the week.
public startOfWeek ( ) : ExpressiveDate
return ExpressiveDate
    public function startOfWeek()
    {
        $this->minusDays($this->getDayOfWeekAsNumeric())->startOfDay();
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * Generates whole week from a specific date
  * @param string
  * @return array
  */
 public static function getWeek($date)
 {
     $week = array();
     $allmonths = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $tempDate = new ExpressiveDate($date);
     $startWeek = $tempDate->startOfWeek()->getDate();
     $currentDay = new ExpressiveDate($startWeek);
     for ($i = 0; $i < 7; $i++) {
         $tempday = array();
         $tempday['day'] = $currentDay->getDay();
         $tempday['year'] = $currentDay->getYear();
         $tempday['dayofweek'] = $currentDay->getDayOfWeek();
         $tempday['month'] = $allmonths[(int) $currentDay->getMonth()];
         $tempday['class'] = 'calendar-day-' . $currentDay->getDate();
         $tempday['date'] = $currentDay->getDate();
         $currentDay = $currentDay->addOneDay();
         $week[] = $tempday;
     }
     return $week;
 }
All Usage Examples Of ExpressiveDate::startOfWeek