| @@ -206,16 +206,18 @@ | ||
| 206 | 206 | $startDate = Arr::get($data, 'start_date'); |
| 207 | 207 | $endDate = Arr::get($data, 'end_date'); |
| 208 | 208 | $formId = Acl::normalizeFormId(Arr::get($data, 'form_id')); |
| 209 | 209 | |
| 210 | - // Set default date range if not provided | |
| 210 | + // Default to the last 30 days, measured on the SITE's clock. created_at is | |
| 211 | + // written by current_time('mysql') and compared here as a raw string, while | |
| 212 | + // PHP's default timezone is UTC under WordPress — so a bare new \DateTime() | |
| 213 | + // would close the window at the end of the UTC day and drop everything | |
| 214 | + // submitted since local midnight on any site east of UTC. | |
| 211 | 215 | if (!$startDate || !$endDate) { |
| 212 | - $now = new \DateTime(); | |
| 213 | - $endDate = $now->format('Y-m-d 23:59:59'); | |
| 216 | + $today = current_time('Y-m-d'); | |
| 214 | 217 | |
| 215 | - $thirtyDaysAgo = new \DateTime(); | |
| 216 | - $thirtyDaysAgo->modify('-30 days'); | |
| 217 | - $startDate = $thirtyDaysAgo->format('Y-m-d 00:00:00'); | |
| 218 | + $endDate = $today . ' 23:59:59'; | |
| 219 | + $startDate = (new \DateTime($today))->modify('-30 days')->format('Y-m-d 00:00:00'); | |
| 218 | 220 | } |
| 219 | 221 | |
| 220 | 222 | return [ |
| 221 | 223 | 'start_date' => $startDate, |