You are here

protected function StatsPro::get_first_day_of_week_from_reference in Statistics Pro 6.2

Same name and namespace in other branches
  1. 6 statspro.inc \statspro::get_first_day_of_week_from_reference()

Returns a YYYY-MM-DD date representation of the first day of same the week as the reference day.

Parameters

<int> $reference A timestamp representaing the reference day.:

Return value

<int> First day of the same week of the reference day.

2 calls to StatsPro::get_first_day_of_week_from_reference()
StatsPro::get_period in ./statspro.inc
Generate SQL fragment for period query.
StatsPro::get_week_from_reference in ./statspro.inc
Returns a SQL WHERE for the selected week.

File

./statspro.inc, line 273
statspro class for Statistics Pro module.

Class

StatsPro
Manages the data saving and retrieval according to the user defined parameters.

Code

protected function get_first_day_of_week_from_reference($reference, $use_timestamp) {
  $day_of_week = date('w', $reference);
  $first = $day_of_week == 1 ? 'today' : 'previous monday';
  $first = strtotime($first, $reference);
  if (!$use_timestamp) {
    $first = date('Y-m-d', $first);
  }
  return $first;
}