protected function StatsPro::get_last_day_of_month_from_reference in Statistics Pro 6.2
Same name and namespace in other branches
- 6 statspro.inc \statspro::get_last_day_of_month_from_reference()
Returns a YYYY-MM-DD date representation of the last day of same the month as the reference day.
Parameters
<int> $reference A timestamp representaing the reference day.:
Return value
<int> Last day of the same month of the reference day.
1 call to StatsPro::get_last_day_of_month_from_reference()
- StatsPro::get_month_from_reference in ./
statspro.inc - Returns a SQL WHERE for the selected month.
File
- ./
statspro.inc, line 322 - statspro class for Statistics Pro module.
Class
- StatsPro
- Manages the data saving and retrieval according to the user defined parameters.
Code
protected function get_last_day_of_month_from_reference($reference, $use_timestamp) {
$year = date('Y', $reference);
$month = date('m', $reference);
if ($use_timestamp) {
$last = $month == 12 ? $year + 1 . '-01-01' : sprintf('%04u-%02u-01', $year, $month + 1);
}
else {
$last = $month == 12 ? $year . '-12-31' : sprintf('%04u-%02u-00', $year, $month + 1);
}
$last = strtotime($last);
if (!$use_timestamp) {
$last = date('Y-m-d', $last);
}
return $last;
}