|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-12-04 06:27 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 21:00:01 2025 UTC |
Tried set date_default_timezone_set('Asia/Shanghai'); but the problem is still exists. OS: Windows VistaIf 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