You are here

private function MatomoReportsController::selectPeriod in Matomo Reports 8

Helper function.

Returns the starting and ending dates according to the selected period.

Parameters

int $period: Selected period.

Return value

string Formatted date.

1 call to MatomoReportsController::selectPeriod()
MatomoReportsController::reports in src/Controller/MatomoReportsController.php
Reports.

File

src/Controller/MatomoReportsController.php, line 344

Class

MatomoReportsController
Class MatomoReportsController.

Namespace

Drupal\matomo_reports\Controller

Code

private function selectPeriod($period) {
  switch ($period) {
    case 0:
      $date = date("Y-m-d");
      break;
    case 1:
      $d = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
      $date = date("Y-m-d", $d);
      break;
    case 2:
      $d = mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"));
      $date = date("Y-m-d", $d);
      break;
    case 3:
      $d = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
      $date = date("Y-m-d", $d);
      break;
    case 4:
      $d = mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1);
      $date = date("Y-m-d", $d);
      break;
  }
  return $date;
}