27 lines
469 B
Go
27 lines
469 B
Go
//
|
|
// time_helper.go
|
|
// Copyright (C) 2022 tiglog <me@tiglog.com>
|
|
//
|
|
// Distributed under terms of the MIT license.
|
|
//
|
|
|
|
package helper
|
|
|
|
import "time"
|
|
|
|
func Format(ts int64, layout string) string {
|
|
return time.Unix(ts, 0).Format(layout)
|
|
}
|
|
|
|
func FormatDate(ts int64) string {
|
|
return Format(ts, "2006-01-02")
|
|
}
|
|
|
|
func FormatDt(ts int64) string {
|
|
return Format(ts, "2006-01-02 15:04")
|
|
}
|
|
|
|
func FormatDateTime(ts int64) string {
|
|
return Format(ts, "2006-01-02 15:04:05")
|
|
}
|