1 | <?php |
||
10 | class DateTimeHelper |
||
11 | { |
||
12 | // Second amounts for various time increments |
||
13 | const YEAR = 31556926; |
||
14 | const LEAP_YEAR = 31622400; |
||
15 | const MONTH = 2629744; |
||
16 | const WEEK = 604800; |
||
17 | const DAY = 86400; |
||
18 | const HOUR = 3600; |
||
19 | const MINUTE = 60; |
||
20 | |||
21 | const DATEFORMAT_MYSQL_DATE = 'Y-m-d'; |
||
22 | const DATEFORMAT_MYSQL_DATETIME = 'Y-m-d H:i:s'; |
||
23 | |||
24 | /** |
||
25 | * Get dates by period |
||
26 | * |
||
27 | * @param mixed $startDate |
||
28 | * @param mixed $endDate |
||
29 | * @param string $format |
||
30 | * @param int $step |
||
31 | * @return array |
||
32 | * @throws \Exception |
||
33 | */ |
||
34 | public function getDatesListByPeriod($startDate, $endDate, $format = null, $step = self::DAY) |
||
49 | |||
50 | /** |
||
51 | * Execute by period |
||
52 | * |
||
53 | * @param mixed $startDate |
||
54 | * @param mixed $endDate |
||
55 | * @param \Closure $function |
||
56 | * @param int $step |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | public function executeByPeriod($startDate, $endDate, $function, $step = self::DAY) |
||
72 | } |