How to get seconds difference between now and old date in Go

1 Answer

0 votes
package main
    
import (
    "fmt"
    "time"
)
    
func main() {
    dt1 := time.Date(2020, 8, 16, 13, 42, 26, 3216532101, time.UTC)
    dt2 := time.Date(2020, 8, 15, 13, 42, 26, 3216532101, time.UTC)
      
    diff := dt1.Sub(dt2)
      
    seconds := int(diff.Seconds())
  
    fmt.Println(seconds)
}
   
   
 
/*
run:
  
86400
  
*/

 



answered Aug 16, 2020 by avibootz

Related questions

1 answer 168 views
1 answer 176 views
1 answer 98 views
2 answers 134 views
2 answers 201 views
1 answer 175 views
...