我正在使用codeigniter,我想让用户获得当前的日期和时间。
获取错误Message: file_get_contents(http://ip-api.com/json/[ip]): failed to open stream: An attempt was made to access a socket in a way forbidden by its access permissions.
$xipx = $_SERVER['REMOTE_ADDR'];
$xdetails = json_decode(file_get_contents("http://ip-api.com/json/{$xipx}"));
$timex = $xdetails->timezone;
$UTC = new DateTimeZone("UTC");
$newTZ = new DateTimeZone($timex);
$date = new DateTime( "now" , $UTC );
$date->setTimezone( $newTZ );
echo $date->format('Y-m-d H:i:s');