אם תצטרכו אי פעם לקבל את איזור הזמן של המשתמש ב-PHP (כולל offset) תוכלו להשתמש בהרחבת GeoIP:
<?php
if ($_REQUEST['ip']) {
$ip = $_REQUEST['ip'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$record = geoip_record_by_name($ip);
if (is_array($record)) {
$country = $record['country_code'];
$region = $record['region'];
$tz = geoip_time_zone_by_country_and_region($record['country_code'], $record['region']);
if ($tz) {
$tzdate = new DateTimeZone($tz);
$dt = new DateTime("now", $tzdate);
$tzoffset = $tzdate->getOffset($dt);
}
}echo "your ip is: " . $ip . "<br/>";
echo "your country is: " . $country . "<br/>";
echo "your timezone is: " . $tz . "<br/>";
echo "your timezone offset is: " . $tzoffset . " seconds<br/>";
?>
כדי להשתמש ב-GeoIP תצטרכו להתקין את חבילת ההרחבה של GeoIP (חפשו במאגר החבילות שלך בלינוקס). בנוסף תצטרכו להוריד ולהתקין את נתוני הערים והאיזורים (regions) ידנית בשביל שהסקריפט יעבוד. הורדה אפשרית מכאן. תצטרכו להעביר את הקובץ לתיקייה: /usr/share/GeoIP/ ולקרוא לקובץ בשם GeoIPCity.dat.
מידע נוסף