From b07738814e37ac039715f04577b55bf43bbefb88 Mon Sep 17 00:00:00 2001 From: danieljankowski Date: Tue, 4 May 2021 11:02:29 +0200 Subject: [PATCH] ASN1: fix timezone issue when non-utc time is given --- phpseclib/File/ASN1.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 1419c097..a9f20e05 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -1093,7 +1093,10 @@ class File_ASN1 if (!class_exists('DateTime')) { $value = @gmdate($format, strtotime($source)) . 'Z'; } else { + // if $source does _not_ include timezone information within it then assume that the timezone is GMT $date = new DateTime($source, new DateTimeZone('GMT')); + // if $source _does_ include timezone information within it then convert the time to GMT + $date->setTimezone(new DateTimeZone('GMT')); $value = $date->format($format) . 'Z'; } break;