/****************************************************************************************************************/ /* Description: This snippet is provide simple way to help user display Visitor's Local Time. */ /* suggestions for different city locations across the country. */ /* There are 1 steps in this snippet. For information, please visit IP2Location tutorial page at: */ /* https://www.ip2location.com/tutorials/display-visitors-local-time-using-php-and-mysql-database */ /****************************************************************************************************************/ /* You can obtain free IP2Location DB11 LITE database for IPv4 at */ /*https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude-zipcode-timezone */ = 24) { $hour = $utc_h[0] + $time[0] - 24; } else { $hour = $utc_h[0] + $time[0]; } $localdate = $hour . gmdate(":i:s"); } date_default_timezone_set("Asia/Kuala_Lumpur"); $date = date_create($localdate); echo 'Country Code: ' . $country_code . '
'; echo 'Local Time: ' . date_format($date, "H:i:s"). '
'; echo 'Server Time: ' . strftime("%H:%M:%S") . '
'; echo 'UTC Time: ' . gmdate("H:i:s") . '
'; // Function to convert IP address (xxx.xxx.xxx.xxx) to IP number (0 to 256^4-1) function Dot2LongIP ($IPaddr) { if ($IPaddr == "") { return 0; } else { $ips = explode(".", $IPaddr); return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256); } } ?>