Skip to content

Instantly share code, notes, and snippets.

@nadimattari
Last active January 21, 2023 13:25
Show Gist options
  • Save nadimattari/7b95eb6b8b6335414872803ea6d0c791 to your computer and use it in GitHub Desktop.
Save nadimattari/7b95eb6b8b6335414872803ea6d0c791 to your computer and use it in GitHub Desktop.
Auqaat-us-salah
<?php
date_default_timezone_set('Indian/Mauritius');
$auqat['YEAR'] = implode(' | ', [
'FAJR -18',
'SUNRISE ',
'DAHWAeKU',
'ZOHR ',
'MAGHRIB ',
'ESHA +18',
]);
$auqat['----'] = implode(' | ', [
'--------',
'--------',
'--------',
'--------',
'--------',
'--------',
]);
$location = [
'lat' => -20.054,
'lng' => 57.545,
];
$date = date('m-d'); // today "mm-dd"
for ($y = 2022; $y <= 2047; $y++) {
$sun_info = date_sun_info(
strtotime("{$y}-{$date}"),
$location['lat'],
$location['lng']
);
$sun_info['zawaal--zohr-starts'] = $sun_info['sunrise'] + ($sun_info['sunset'] - $sun_info['sunrise']) / 2;
$sun_info['dahwa-e-kubra'] = $sun_info['astronomical_twilight_begin'] + ($sun_info['sunset'] - $sun_info['astronomical_twilight_begin']) / 2;
foreach ($sun_info as $key => $val) {
$sun_info[$key] = date("H:i:s", (int)$val);
}
$auqat[$y] = implode(' | ', [
$sun_info['astronomical_twilight_begin'],
$sun_info['sunrise'],
$sun_info['dahwa-e-kubra'],
$sun_info['zawaal--zohr-starts'],
$sun_info['sunset'],
$sun_info['astronomical_twilight_end'],
]);
}
echo json_encode([date('d-F') => $auqat], JSON_PRETTY_PRINT);
@nadimattari
Copy link
Author

nadimattari commented Jan 21, 2023

Sample output

{
    "21-January": {
        "YEAR": "FAJR -18 | SUNRISE  | DAHWAeKU | ZOHR     | MAGHRIB  | ESHA +18",
        "----": "-------- | -------- | -------- | -------- | -------- | --------",
        "2022": "04:25:52 | 05:45:41 | 11:41:09 | 12:21:04 | 18:56:27 | 20:16:16",
        "2023": "04:25:40 | 05:45:31 | 11:41:04 | 12:20:59 | 18:56:28 | 20:16:20",
        "2024": "04:25:27 | 05:45:21 | 11:40:58 | 12:20:55 | 18:56:29 | 20:16:23",
        "2025": "04:26:05 | 05:45:51 | 11:41:15 | 12:21:08 | 18:56:25 | 20:16:11",
        "2026": "04:25:53 | 05:45:41 | 11:41:09 | 12:21:03 | 18:56:26 | 20:16:15",
        "2027": "04:25:40 | 05:45:32 | 11:41:03 | 12:20:59 | 18:56:27 | 20:16:19",
        "2028": "04:25:28 | 05:45:22 | 11:40:58 | 12:20:55 | 18:56:29 | 20:16:22",
        "2029": "04:26:06 | 05:45:52 | 11:41:15 | 12:21:08 | 18:56:24 | 20:16:10",
        "2030": "04:25:54 | 05:45:42 | 11:41:09 | 12:21:03 | 18:56:25 | 20:16:14",
        "2031": "04:25:41 | 05:45:32 | 11:41:04 | 12:20:59 | 18:56:27 | 20:16:17",
        "2032": "04:25:29 | 05:45:23 | 11:40:58 | 12:20:55 | 18:56:28 | 20:16:21",
        "2033": "04:26:07 | 05:45:52 | 11:41:15 | 12:21:07 | 18:56:23 | 20:16:09",
        "2034": "04:25:55 | 05:45:43 | 11:41:09 | 12:21:03 | 18:56:24 | 20:16:13",
        "2035": "04:25:42 | 05:45:33 | 11:41:04 | 12:20:59 | 18:56:26 | 20:16:16",
        "2036": "04:25:30 | 05:45:23 | 11:40:58 | 12:20:55 | 18:56:27 | 20:16:20",
        "2037": "04:26:08 | 05:45:53 | 11:41:15 | 12:21:07 | 18:56:22 | 20:16:08",
        "2038": "04:25:56 | 05:45:43 | 11:41:10 | 12:21:03 | 18:56:24 | 20:16:12",
        "2039": "04:25:43 | 05:45:34 | 11:41:04 | 12:20:59 | 18:56:25 | 20:16:15",
        "2040": "04:25:31 | 05:45:24 | 11:40:58 | 12:20:55 | 18:56:26 | 20:16:19",
        "2041": "04:26:09 | 05:45:54 | 11:41:15 | 12:21:08 | 18:56:22 | 20:16:07",
        "2042": "04:25:56 | 05:45:44 | 11:41:09 | 12:21:03 | 18:56:23 | 20:16:10",
        "2043": "04:25:44 | 05:45:34 | 11:41:04 | 12:20:59 | 18:56:24 | 20:16:14",
        "2044": "04:25:32 | 05:45:24 | 11:40:58 | 12:20:54 | 18:56:25 | 20:16:18",
        "2045": "04:26:10 | 05:45:54 | 11:41:15 | 12:21:07 | 18:56:21 | 20:16:05",
        "2046": "04:25:57 | 05:45:45 | 11:41:09 | 12:21:03 | 18:56:22 | 20:16:09",
        "2047": "04:25:45 | 05:45:35 | 11:41:04 | 12:20:59 | 18:56:23 | 20:16:13"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment