From 19a6f218e6ad60ef2d9d403feec7c4837649b3a7 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sat, 19 Mar 2022 18:23:06 +0800 Subject: [PATCH] fix: format time in local timezone --- datetime/conversion.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datetime/conversion.go b/datetime/conversion.go index ddf01fb..c317378 100644 --- a/datetime/conversion.go +++ b/datetime/conversion.go @@ -46,15 +46,15 @@ func (t *theTime) ToUnix() int64 { // ToFormat return the time string 'yyyy-mm-dd hh:mm:ss' of unix time func (t *theTime) ToFormat() string { - return time.Unix(t.unix, 0).Format("2006-01-02 15:04:05") + return time.Unix(t.unix, 0).Local().Format("2006-01-02 15:04:05") } // ToFormatForTpl return the time string which format is specified tpl func (t *theTime) ToFormatForTpl(tpl string) string { - return time.Unix(t.unix, 0).Format(tpl) + return time.Unix(t.unix, 0).Local().Format(tpl) } // ToFormatForTpl return iso8601 time string func (t *theTime) ToIso8601() string { - return time.Unix(t.unix, 0).Format(time.RFC3339) + return time.Unix(t.unix, 0).Local().Format(time.RFC3339) }