first commit

This commit is contained in:
vedant-chavan
2024-06-12 20:29:05 +05:30
commit eff0228447
246 changed files with 25388 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
use GeoIp2\Database\Reader;
function getCountryTimeZone($userSelectedCountry)
{
// Path to the GeoIP2 database file
$databasePath = storage_path('app/GeoLite2-Country.mmdb'); // Replace with the path to your downloaded database file
// Initialize the GeoIP2 reader
$reader = new Reader($databasePath);
try {
// Look up the country for the user's selected IP address or country code
$record = $reader->country($userSelectedCountry);
// Get the time zone from the country data
$timeZone = $record->location->timeZone;
return $timeZone;
} catch (\Exception $e) {
// Handle exceptions if the country code or IP address is not found
return 'UTC'; // Default to UTC if not found
}
}