Skip to content

Instantly share code, notes, and snippets.

@EnriqueSoria
Created November 14, 2025 08:40
Show Gist options
  • Select an option

  • Save EnriqueSoria/a1482a59c64c716cc71eaefd67926325 to your computer and use it in GitHub Desktop.

Select an option

Save EnriqueSoria/a1482a59c64c716cc71eaefd67926325 to your computer and use it in GitHub Desktop.
Create random datetimes
import datetime
import random
def create_random_datetime_between_dates(
start: datetime.datetime,
end: datetime.datetime,
) -> datetime.datetime:
random_timestamp = random.uniform(start.timestamp(), end.timestamp())
return datetime.datetime.fromtimestamp(random_timestamp)
@EnriqueSoria
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment