Skip to content

Instantly share code, notes, and snippets.

@Mez0
Last active December 2, 2024 13:21
Show Gist options
  • Save Mez0/93c53ca40d28e50f6e4a5d923e643c87 to your computer and use it in GitHub Desktop.
Save Mez0/93c53ca40d28e50f6e4a5d923e643c87 to your computer and use it in GitHub Desktop.
Swift Generate Random Date
extension Date {
static func random() -> Date {
let randomTime = TimeInterval(Int32.random(in: 0...Int32.max))
return Date(timeIntervalSince1970: randomTime)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment