I want to get the current time from the server using ip so i am using ap-api for that, but it is free for 45 reqests per minute . so can you suggest some other methods i will post my code below
function get_user_time_zone() {
$ip_address = $_SERVER['REMOTE_ADDR'];
$response = wp_remote_get('http://ip-api.com/json/');
if (is_wp_error($response)) {
return 'UTC';
}
$data = json_decode(wp_remote_retrieve_body($response));
return $data && isset($data->timezone) ? $data->timezone : 'UTC';
}