Random Future Date Generator

  • Share this:

Code introduction


This function generates a future date that is a random number of days from today, with a default year of 2025 and a random number of days between 1 and 10.


Technology Stack : Delorean, random

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
def random_future_date(year=2025, days=10):
    from delorean import Delorean
    import random
    
    # Create a Delorean object for today's date
    today = Delorean()
    
    # Generate a random number of days to add to today
    random_days = random.randint(1, days)
    
    # Add the random days to today's date to get a future date
    future_date = today + random_days
    
    # Return the future date as a string
    return future_date.date()