I'm trying to do an script that returns the year, month and day but the response is always the same : 1970-01-01
.
I can't understand, it should change on every link and "google" ssl expiration date is not 1970-01-01
So, someone can see the error in the code?
$url = "https://www.google.es/";
$orignal_parse = parse_url($url, PHP_URL_HOST);
$get = stream_context_create(array(
"ssl" => array(
"capture_peer_cert" => TRUE
)
));
$read = stream_socket_client("ssl://" . $orignal_parse . ":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get);
$cert = stream_context_get_params($read);
$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']);
$valid_to = date(DATE_RFC2822, $certinfo['validTo_time_t']);
$time = strtotime($valid_to);
$month = date("F",$time);
$year = date('Y', $time);
$day = date('j', $time);
if ($month = "Januay") {
$month = "01";
} else if ($month = "February") {
$month = "02";
} else if ($month = "March") {
$month = "03";
} else if ($month = "April") {
$month = "04";
} else if ($month = "May") {
$month = "05";
} else if ($month = "June") {
$month = "06";
} else if ($month = "July") {
$month = "07";
} else if ($month = "August") {
$month = "08";
} else if ($month = "September") {
$month = "09";
} else if ($month = "October") {
$month = "10";
} else if ($month = "November") {
$month = "11";
} else if ($month = "December") {
$month = "12";
}
$strtime = strtotime($day ."/" . $month . "/" . $year);
$newdate = date('Y-m-d',$strtime);
echo $newdate;