mirror of
https://gitee.com/johng/gf
synced 2026-07-08 14:39:50 +08:00
Package gview: build-in function 'date' supports printing current datetime.
This commit is contained in:
@ -290,8 +290,14 @@ func (view *View) funcUrlDecode(url interface{}) string {
|
||||
}
|
||||
|
||||
// 模板内置方法:date
|
||||
func (view *View) funcDate(format string, timestamp interface{}) string {
|
||||
return gtime.NewFromTimeStamp(gconv.Int64(timestamp)).Format(format)
|
||||
func (view *View) funcDate(format string, timestamp...interface{}) string {
|
||||
t := int64(0)
|
||||
if len(timestamp) > 0 {
|
||||
t = gconv.Int64(timestamp[0])
|
||||
} else {
|
||||
t = gtime.Millisecond()
|
||||
}
|
||||
return gtime.NewFromTimeStamp(t).Format(format)
|
||||
}
|
||||
|
||||
// 模板内置方法:compare
|
||||
|
||||
@ -502,10 +502,10 @@ func main() {
|
||||
//update1()
|
||||
//update2()
|
||||
//update3()
|
||||
//linkopSelect1()
|
||||
linkopSelect1()
|
||||
//linkopSelect2()
|
||||
//linkopSelect3()
|
||||
linkopCount1()
|
||||
//linkopCount1()
|
||||
//linkopUpdate1()
|
||||
//linkopUpdate2()
|
||||
//linkopUpdate3()
|
||||
|
||||
@ -14,6 +14,7 @@ func main() {
|
||||
{{"https%3A%2F%2Fgfer.me"|urldecode}}
|
||||
{{1540822968 | date "Y-m-d"}}
|
||||
{{"1540822968" | date "Y-m-d H:i:s"}}
|
||||
{{date "Y-m-d H:i:s"}}
|
||||
{{compare "A" "B"}}
|
||||
{{compare "1" "2"}}
|
||||
{{compare 2 1}}
|
||||
|
||||
Reference in New Issue
Block a user