Edit report at https://bugs.php.net/bug.php?id=46747&edit=1
ID: 46747 Comment by: cheef-daniel at freenet dot de Reported by: hunreal at gmail dot com Summary: validFrom_time_t of certificate in Windows is difference with Unix system Status: Not a bug Type: Bug Package: OpenSSL related Operating System: Windows, FreeBSD PHP Version: 5.2.6 Block user comment: N Private report: N New Comment: If this is not a bug, can you please explain why I get wrong results too on Windows Server 2008 R2 + Apache? wrong: 27.03.2021 22:59:59 expected: 28.03.2021 00:59:59 echo phpversion(); 5.3.16 echo date_default_timezone_get(); Europe/Berlin echo $timestamp = $certInfo["validTo_time_t"] 1616882399 echo date("d.m.Y H:i:s", $timestamp) 27.03.2021 22:59:59 openssl x509 -dates -noout -in my.crt notAfter=Mar 27 22:59:59 2021 GMT Previous Comments: ------------------------------------------------------------------------ [2009-01-16 02:18:14] hunreal at gmail dot com Tried set date_default_timezone_set('Asia/Shanghai'); but the problem is still exists. OS: Windows Vista ------------------------------------------------------------------------ [2008-12-08 11:41:46] j...@php.net One of those machines has wrong timezone set. Use the date_default_timezone_set() function in your script to set the correct one in both. And check those machines' system time too. This is not a PHP bug. ------------------------------------------------------------------------ [2008-12-04 06:27:20] hunreal at gmail dot com Description: ------------ I used openssl_x509_parse() to get certificate infomation. But the values, 'validFrom_time_t' and 'validTo_time_t' in Windows is difference with Unix system. It's same php code, same certificate file. But two result is not the same. By used openssl CLI, I am sure that is Windows PHP issue. Reproduce code: --------------- PHP code: <?php $crtinfo = openssl_x509_parse(file_get_contents("my.cer")); echo $crtinfo['validFrom']," ",$crtinfo['validFrom_time_t'],"\n"; echo $crtinfo['validTo']," ",$crtinfo['validTo_time_t'],"\n"; echo date("Y-m-d H:i:s", $crtinfo['validFrom_time_t']),"\n"; echo date("Y-m-d H:i:s", $crtinfo['validTo_time_t']),"\n"; ?> Openssl CLI: openssl x509 -dates -noout -in my.cer You can use any certificate. Expected result: ---------------- In windows, PHP code output, 070126220002Z 1169845202 090126033531Z 1232937331 2007-01-27 05:00:02 2009-01-26 10:35:31 ------------------------------ In Unix, PHP code output, 070126220002Z 1169848802 090126033531Z 1232940931 2007-01-27 06:00:02 2009-01-26 11:35:31 ------------------------------ BTW, my timezone is set to Asia/Shanghai, GMT+8 Actual result: -------------- OpenSSL CLI output, notBefore=Jan 26 22:00:02 2007 GMT notAfter=Jan 26 03:35:31 2009 GMT ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=46747&edit=1