9951 explained code solutions for 126 technologies


golangHow to format a date in "MM/DD/YYYY"


package main

import (
  "fmt"
  "time"
)

func main() {
	ct := time.Now()
	fmt.Println(ct.Format("02/01/2006"))
}ctrl + c
time.Now()

returns current date time

Format

formats datatime

"02/01/2006"

will format date in MM/DD/YYYY