Ai
198 Star 567 Fork 254

lock-li/opms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
date.go 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
www 提交于 2016-10-31 21:48 +08:00 . new version 1.2 for notice,check work etc.
package utils
import (
//"fmt"
"time"
)
/*
func GetDate(timestamp int64) string {
tm := time.Unix(timestamp, 0)
return tm.Format("2006-01-02 15:04")
}
func GetDateMH(timestamp int64) string {
tm := time.Unix(timestamp, 0)
return tm.Format("01-02 03:04")
}*/
func GetDateFormat(timestamp int64, format string) string {
if timestamp <= 0 {
return ""
}
tm := time.Unix(timestamp, 0)
return tm.Format(format)
}
func GetDate(timestamp int64) string {
if timestamp <= 0 {
return ""
}
tm := time.Unix(timestamp, 0)
return tm.Format("2006-01-02")
}
func GetDateMH(timestamp int64) string {
if timestamp <= 0 {
return ""
}
tm := time.Unix(timestamp, 0)
return tm.Format("2006-01-02 15:04")
}
func GetTimeParse(times string) int64 {
if "" == times {
return 0
}
loc, _ := time.LoadLocation("Local")
parse, _ := time.ParseInLocation("2006-01-02 15:04", times, loc)
return parse.Unix()
}
func GetDateParse(dates string) int64 {
if "" == dates {
return 0
}
loc, _ := time.LoadLocation("Local")
parse, _ := time.ParseInLocation("2006-01-02", dates, loc)
return parse.Unix()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lock-upme/opms.git
git@gitee.com:lock-upme/opms.git
lock-upme
opms
opms
558463a10cc0

搜索帮助