Browse Source

DateTime format support

Vova Tkach 6 years ago
parent
commit
a08e5be53e
2 changed files with 9 additions and 0 deletions
  1. 8 0
      engine/fetdata/content.go
  2. 1 0
      hosts/localhost/template/header.html

+ 8 - 0
engine/fetdata/content.go

@@ -2,6 +2,7 @@ package fetdata
 
 import (
 	"html/template"
+	"time"
 
 	"golang-fave/utils"
 )
@@ -33,3 +34,10 @@ func (this *FERData) DateTime() int {
 	}
 	return 0
 }
+
+func (this *FERData) DateTimeFormat(format string) string {
+	if this.Wrap.CurrModule == "index" {
+		return time.Unix(int64(this.DataRow.(*utils.MySql_page).A_datetime), 0).Format(format)
+	}
+	return ""
+}

+ 1 - 0
hosts/localhost/template/header.html

@@ -49,6 +49,7 @@
 			</div>
 			<div class="container some-text pt-3">
 				<div><b>DateTime:</b> {{$.Data.DateTime}}</div>
+				<div><b>DateTimeFormat:</b> {{$.Data.DateTimeFormat "2006-01-02 15:04:05"}}</div>
 			</div>
 			<div class="container some-text pt-3">
 				<h2>User</h2>