Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format todays date in go as dd-mm-yyyy? [duplicate]

Tags:

go

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

like image 865
serps Avatar asked Apr 17 '17 18:04

serps


People also ask

How can I get current date in go?

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.

How do you format mm dd yyyy?

yyyy-MM-dd — Example: 2013-06-23.

How can I get current date in jquery DD MMM YYYY format?

get current date in jquery in dd/mm/yyyy format” Code Answer. var mm = String(today. getMonth() + 1).

How can I convert date in dd mm yyyy in Excel?

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.”


1 Answers

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"))
}
like image 189
Patrick Avatar answered Oct 21 '22 02:10

Patrick