10 examples of 'golang time format' in Go

Every line of 'golang time format' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
118func FormatWithTime(text string) (result string) {
119 result = text
120
121 matches := retime.FindAllStringSubmatch(result, -1)
122 for _, submatches := range matches {
123 value := time.Now().Format(submatches[1])
124 result = strings.Replace(result, submatches[0], value, -1)
125 }
126
127 return
128}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

196func (t *templateFunctions) timeStampFormat(layout string, v map[string]interface{}) string {
197 ts := v["@timestamp"]
198 ti, err := cast.ToTimeE(ts)
199 if err != nil {
200 return ""
201 }
202 return jodaTime.Format(layout, ti)
203}
89func GetUnixTimeStr(ut int64,format string)(string){
90 t := time.Unix(ut,0)
91 return GetTmStr(t,format)
92}
258func inlineParseModeledTime(format, v string) string {
259 const formatTimeTmpl = `func() *time.Time{
260 v, err := protocol.ParseTime("%s", "%s")
261 if err != nil {
262 panic(err)
263 }
264 return &v
265 }()`
266
267 return fmt.Sprintf(formatTimeTmpl, format, v)
268}
338func (c *console) AppendTime(buf *bytes.Buffer, t time.Time) {
339 s := t.Format(timeFormat)
340 appendString(buf, s, false)
341}
238func FmtTime(sec int64, step TimeDelta) string {
239 t := time.Unix(sec, 0)
240 return step.Format(t)
241}
181func formatTime(t time.Time, layout string) string {
182 return t.Format(layout)
183}
15func timeFormat(t time.Time, format string) string {
16 return t.Format(format)
17}
167func parse(format string, t time.Time) string {
168 result := ""
169 for _, s := range format {
170 result += recognize(string(s), t)
171 }
172 return result
173}
37func timeFmtOr(t *time.Time, fmt, def string) string {
38 if t == nil {
39 return def
40 }
41 return t.Format(fmt)
42}

Related snippets