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
Using the “time. Now()” function you can get the date and time in the “yyyy-mm-dd hh:mm:ss. milliseconds timezone” format. This is simplest way for getting the date and time in golang.
yyyy-MM-dd — Example: 2013-06-23.
get current date in jquery in dd/mm/yyyy format” Code Answer. var mm = String(today. getMonth() + 1).
In the “Number” tab, select the option “Custom.” Then, under “Type,” enter or choose the format “dd-mmm-yyyy.” The same is shown in the following image. If the sample date looks alright, click “OK.”
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"))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With