Last active
June 24, 2021 18:55
-
-
Save djberg96/6cb41a2e45724d529578a072138c5243 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"math/rand" | |
) | |
func randate() time.Time { | |
min := time.Date(1970, 1, 0, 0, 0, 0, 0, time.UTC).Unix() | |
max := time.Date(2070, 1, 0, 0, 0, 0, 0, time.UTC).Unix() | |
delta := max - min | |
sec := rand.Int63n(delta) + min | |
return time.Unix(sec, 0) | |
} | |
func main() { | |
fmt.Println("Random:", randate()) /* go run produces same date every time */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment