Python Date Time

DateTime Object

import datetime

# DateTime Object (Stores Object Date and Time)
now = datetime.datetime.now()

# Date Object
today = now.date()

# Time Object
moment = now.time()

TimeDelta Object

delta_1 = datetime.timedelta(days=1)
delta_2 = datetime.timedelta(months=1)

tomorrow = today + delta_1
print tomorrow

Convert String to Date and Vice Versa

# String to Date
week_start = datetime.datetime.strptime(week_date_str, "%m/%d/%Y")

# Date to String
week_date_str = week_start_date.strftime('%Y-%m-%d')