From ec80aa951fd207e0d5752e3d7bb38cad596bd885 Mon Sep 17 00:00:00 2001 From: reipay Date: Fri, 5 Apr 2024 01:18:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EgetUnixTimestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Support/Utils.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Support/Utils.php b/src/Support/Utils.php index 2e60db5..6d3df7b 100644 --- a/src/Support/Utils.php +++ b/src/Support/Utils.php @@ -735,4 +735,21 @@ public static function getPublicKeyFromPrivateKey($private_key) { $keyPair = $ec->keyFromPrivate($private_key); return $keyPair->getPublic()->encode('hex'); } + + /** + * 获取指点时间戳的Unix + */ + public static function getUnixTimestamp($minute = 0, $need_millisecond = true){ + if($minute == 0){ + $symbol = "now"; + } + else if($minute > 0){ + $symbol = "+{$minute}"; + } + else{ + $symbol = "{$minute}"; + } + + return $need_millisecond ? strtotime($symbol)."000" : strtotime($symbol); + } } \ No newline at end of file