Skip to content

Commit

Permalink
Added random datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
leomariga committed Jul 18, 2019
1 parent 9f536c2 commit e83c936
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions randomdatetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from datetime import datetime, timedelta
import random

def gen_datetime(min_year=2018, max_year=datetime.now().year):

start = datetime(min_year, 1, 1, 00, 00, 00)

years = max_year - min_year + 1

end = start + timedelta(days=365 * years)

return start + (end - start) * random.random()


randomTime = str(gen_datetime())
print(randomTime)

0 comments on commit e83c936

Please sign in to comment.