You don't have to update your code. You probably have to update your server.
Use this code on a new blank page:
<?php
$ch = curl_init('https://www.howsmyssl.com/a/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
echo $json->tls_version;
?>
It will tell you the TLS version your site has installed and it if isn't 1.2 or greater, then contact your hosting provider and have them update it for you.