From 0b2fced0ef0c743c4d0f776d17674e43c0cbb9be Mon Sep 17 00:00:00 2001 From: CHENCHI MA Date: Wed, 20 Dec 2017 17:27:19 +0800 Subject: [PATCH 1/2] Fix date time zone issue Aliyun Direct Mail service api use UTC timezone,so we should set utc and cover back to app's timezone. --- src/DirectMailTransport.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DirectMailTransport.php b/src/DirectMailTransport.php index d521ef8..c43169f 100644 --- a/src/DirectMailTransport.php +++ b/src/DirectMailTransport.php @@ -27,6 +27,7 @@ class DirectMailTransport extends Transport */ public function __construct($AccessKeyId, $AccessSecret, $ReplyToAddress, $AddressType) { + date_default_timezone_set('UTC'); $this->AccessKeyId = $AccessKeyId; $this->AccessSecret = $AccessSecret; $this->ReplyToAddress = $ReplyToAddress; @@ -39,6 +40,7 @@ public function __construct($AccessKeyId, $AccessSecret, $ReplyToAddress, $Addre $this->CommonParameters['Timestamp'] = date('Y-m-d\TH:i:s\Z'); $this->CommonParameters['SignatureVersion'] = '1.0'; $this->CommonParameters['SignatureNonce'] = uniqid(); + date_default_timezone_set(config('app.timezone')); } /** From b28e2ff96054595f665b3942ddceceb2fbd67d71 Mon Sep 17 00:00:00 2001 From: CHENCHI MA Date: Fri, 22 Dec 2017 14:37:43 +0800 Subject: [PATCH 2/2] use gmdate instead of date function --- src/DirectMailTransport.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/DirectMailTransport.php b/src/DirectMailTransport.php index c43169f..5ade8bf 100644 --- a/src/DirectMailTransport.php +++ b/src/DirectMailTransport.php @@ -27,7 +27,6 @@ class DirectMailTransport extends Transport */ public function __construct($AccessKeyId, $AccessSecret, $ReplyToAddress, $AddressType) { - date_default_timezone_set('UTC'); $this->AccessKeyId = $AccessKeyId; $this->AccessSecret = $AccessSecret; $this->ReplyToAddress = $ReplyToAddress; @@ -37,10 +36,9 @@ public function __construct($AccessKeyId, $AccessSecret, $ReplyToAddress, $Addre $this->CommonParameters['Version'] = '2015-11-23'; $this->CommonParameters['AccessKeyId'] = $AccessKeyId; $this->CommonParameters['SignatureMethod'] = 'HMAC-SHA1'; - $this->CommonParameters['Timestamp'] = date('Y-m-d\TH:i:s\Z'); + $this->CommonParameters['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $this->CommonParameters['SignatureVersion'] = '1.0'; $this->CommonParameters['SignatureNonce'] = uniqid(); - date_default_timezone_set(config('app.timezone')); } /**