You can download this code by clicking the button below.
This code is now available for download.
This function generates a string representation of a UTC time, which is the current time shifted forward or backward by a random number of days and hours. The time can be up to 30 days in the past or future.
Technology Stack : Arrow
Code Type : The type of code
Code Difficulty : Intermediate
import random
import arrow
from arrow import utc
def random_time_string():
time = utc.now().shift(days=random.randint(-30, 30), hours=random.randint(0, 24))
return time.format("YYYY-MM-DD HH:mm:ss")