Add timestamp func date

tags/v1.0.9 v1.0.9
Stanly 4 years ago
parent 658a912c58
commit 7ca8b5f462

@ -6,6 +6,7 @@ import (
// 格式化 // 格式化
const ( const (
FormatDate = "2006-01-02"
FormatDatetime = "2006-01-02 15:04:05" FormatDatetime = "2006-01-02 15:04:05"
) )
@ -47,6 +48,14 @@ func (t Timestamp) Time() time.Time {
return time.Unix(t.Int64(), 0) return time.Unix(t.Int64(), 0)
} }
// Date 回傳日期字串
func (t Timestamp) Date() string {
return time.
Unix(t.Int64(), 0).
In(Local).
Format(FormatDate)
}
// Datetime 回傳時間字串 // Datetime 回傳時間字串
func (t Timestamp) Datetime() string { func (t Timestamp) Datetime() string {
return time. return time.

Loading…
Cancel
Save