Search code examples
phpopensslssl-certificatephp-openssl

Get openssl certificate expiration date


I've parsed openssl certificate by openssl_x509_parse() function and got an array as a result.

Now I need to get the expiration time of that certificate. In parsed array I have validTo_time_t element which contains a valid unix timestamp. But how to determine what timezone this timestamp belongs for?

So I can't get the real expiration time because that timestamp because it means deifferent dates on different timezones.


Solution

  • php formats this field using it's default timezone. you can get it using http://docs.php.net/date_default_timezone_get function

    and once you know the timezone you can convert it to UTC or whatever you need