How to declare date and time in Go

1 Answer

0 votes
package main
  
import (
    "fmt"
    "time"
)
  
func main() {
    t := time.Date(2020, 5, 27, 9, 06, 21, 0, time.UTC) 
  
    fmt.Printf("%v\n", t.Year()) 
    fmt.Printf("%v\n", t.Month()) 
    fmt.Printf("%v\n", t.Day()) 

    fmt.Printf("%v:%v:%v\n", t.Hour(), t.Minute(), t.Second()) 

    fmt.Printf("%v\n", t) 
}
  
  
  
  
/*
run:
  
2020
May
27
9:6:21
2020-05-27 09:06:21 +0000 UTC
  
*/

 



answered May 27, 2020 by avibootz

Related questions

1 answer 255 views
1 answer 118 views
1 answer 166 views
1 answer 177 views
1 answer 168 views
7 answers 565 views
565 views asked Aug 7, 2020 by avibootz
1 answer 174 views
174 views asked Aug 7, 2020 by avibootz
...