| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 2.1.14 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2024 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Analytics\Ajax; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
Trait Shared |
| 20 |
{ |
| 21 |
protected function getPreviousPeriodDates($startDate, $period) |
| 22 |
{ |
| 23 |
if (!\DateTime::createFromFormat('Y/m/d 00:00:00', $startDate)) |
| 24 |
{ |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
$newStartDate = new \DateTime($startDate); |
| 29 |
$newStartDate->sub(new \DateInterval("P{$period}D")); |
| 30 |
$newStartDateStr = $newStartDate->format('Y/m/d 00:00:00'); |
| 31 |
|
| 32 |
$period--; |
| 33 |
$newEndDate = clone $newStartDate; |
| 34 |
$newEndDate->add(new \DateInterval("P{$period}D")); |
| 35 |
$newEndDateStr = $newEndDate->format('Y/m/d 23:59:59'); |
| 36 |
|
| 37 |
return [$newStartDateStr, $newEndDateStr]; |
| 38 |
} |
| 39 |
} |