You can download this code by clicking the button below.
This code is now available for download.
This function generates a random date between two given dates.
Technology Stack : The packages and technology stack used in the code[English]: datetime, random
Code Type : Function
Code Difficulty : Intermediate
def random_date(start, end):
import random
from datetime import datetime, timedelta
def random_date_generator(start, end):
delta = end - start
random_seconds = random.randrange(delta.total_seconds())
return start + timedelta(seconds=random_seconds)
return random_date_generator(start, end)