Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 473 Bytes

how-to-format-time-in-hhmmss.md

File metadata and controls

43 lines (31 loc) · 473 Bytes

How to format time in "HH:MM:SS"

package main

import (
  "fmt"
  "time"
)

func main() {
	ct := time.Now()
	fmt.Println(ct.Format("15:04:05"))
}
  • time.Now() - returns current date time
  • Format - formats datatime
  • "15:04:05" - will format date in HH:MM:SS

group: date

Example:

package main

import (
  "fmt"
  "time"
)

func main() {
	ct := time.Now()
	fmt.Println(ct.Format("15:04:05"))
}
16:16:56