7

I am trying to format todays date in golang and seem to be struggling with something i deem to be quite simple.

I am trying to get todays date in the format of dd-mm-yyy

any ideas?

thanks

serps
  • 221
  • 1
  • 4
  • 13
  • 1
    In which database n also u can simply get the result by google – Rams Apr 17 '17 at 18:07
  • i did not mention anything to do with databases @Rams? i will check that answer @NaveenKumarNamachivayam – serps Apr 17 '17 at 18:47
  • best answer here http://stackoverflow.com/a/39287194/2152652 – serps Apr 17 '17 at 19:01
  • I disagree that this is duplicated question. Provided answers show American date formats, which have nothing to do with the formats used in most European countries. – edufinn Jan 06 '19 at 16:13

1 Answers1

25

It works this way in Go Playground: https://play.golang.org/p/kBjTxZS9Y7

Here is the code:

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println(time.Now().Format("02-01-2006"))
}
Patrick
  • 2,889
  • 1
  • 24
  • 24