时间工具支持传入layout

This commit is contained in:
白茶清欢 2023-04-08 14:48:53 +08:00
parent f5fddb92e8
commit 82a530d779
1 changed files with 5 additions and 2 deletions

View File

@ -26,8 +26,11 @@ type ownTime struct {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 1:34 上午 2021/10/7
func (ot *ownTime) GetCurrentFormatTime() string {
return time.Now().In(time.Local).Format("2006-01-02 15:04:05")
func (ot *ownTime) GetCurrentFormatTime(layout ...string) string {
if len(layout) == 0 {
layout = []string{"2006-01-02 15:04:05"}
}
return time.Now().In(time.Local).Format(layout[0])
}
// FormatUnixNano 格式化纳秒时间戳