From 6710e345ccec831d13147a7cb8b0240657d8c207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 19 Mar 2023 14:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- time.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/time.go b/time.go index d57abb0..bd3ba82 100644 --- a/time.go +++ b/time.go @@ -26,7 +26,7 @@ type ownTime struct { // // Date : 1:34 上午 2021/10/7 func (ot *ownTime) GetCurrentFormatTime() string { - return time.Now().Format("2006-01-02 15:04:05") + return time.Now().In(time.Local).Format("2006-01-02 15:04:05") } // FormatUnixNano 格式化纳秒时间戳 @@ -46,7 +46,7 @@ func (ot *ownTime) FormatUnixNano(timestamp int64) string { // // Date : 11:55 2022/7/14 func (ot *ownTime) FormatUnixMilli(timestamp int64) string { - return time.UnixMilli(timestamp).Format("2006-01-02 15:04:05.000") + return time.UnixMilli(timestamp).In(time.Local).Format("2006-01-02 15:04:05.000") } // FormatUnixSec ... @@ -55,7 +55,7 @@ func (ot *ownTime) FormatUnixMilli(timestamp int64) string { // // Date : 12:06 2022/7/14 func (ot *ownTime) FormatUnixSec(timestamp int64) string { - return time.Unix(timestamp, 0).Format("2006-01-02 15:04:05") + return time.Unix(timestamp, 0).In(time.Local).Format("2006-01-02 15:04:05") } // ParseISO8601Time 解析 2006-01-02T15:04:05+08:00 格式时间 -> 2006-01-02 15:04:05 @@ -74,5 +74,5 @@ func (ot *ownTime) ParseISO8601Time(parseTime string) string { return "" } - return formatTime.Format("2006-01-02 15:04:05") + return formatTime.In(time.Local).Format("2006-01-02 15:04:05") }