-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimezone_list.php
More file actions
40 lines (32 loc) · 1.09 KB
/
timezone_list.php
File metadata and controls
40 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once 'api/config.php';
try {
$jsonFile = __DIR__ . '/json/timezone.json';
if (!file_exists($jsonFile)) {
sendError('Timezone data file not found', 404);
}
$jsonContent = file_get_contents($jsonFile);
$data = json_decode($jsonContent, true);
if (!isset($data['timezones']) || !is_array($data['timezones'])) {
sendError('Invalid timezone data format', 500);
}
$timezoneList = [];
foreach ($data['timezones'] as $timezone) {
$timezoneList[] = [
'timezone_id' => $timezone['timezone_id'] ?? null,
'timezone_name' => $timezone['timezone_name'] ?? null,
'utc_offset' => $timezone['utc_offset'] ?? null,
'region' => $timezone['region'] ?? null,
'iana_timezone' => $timezone['iana_timezone'] ?? null
];
}
$result = [
'success' => true,
'total' => count($timezoneList),
'timezones' => $timezoneList
];
sendSuccess($result);
} catch (Exception $e) {
sendError('Error: ' . $e->getMessage(), 500);
}
?>