1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-17 03:02:28 +08:00

fix: format time in local timezone

This commit is contained in:
dudaodong
2022-03-19 18:23:06 +08:00
parent ccaf290b63
commit 19a6f218e6

View File

@@ -46,15 +46,15 @@ func (t *theTime) ToUnix() int64 {
// ToFormat return the time string 'yyyy-mm-dd hh:mm:ss' of unix time // ToFormat return the time string 'yyyy-mm-dd hh:mm:ss' of unix time
func (t *theTime) ToFormat() string { 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 // ToFormatForTpl return the time string which format is specified tpl
func (t *theTime) ToFormatForTpl(tpl string) string { 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 // ToFormatForTpl return iso8601 time string
func (t *theTime) ToIso8601() 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)
} }