Python Dates and Time

The DateTime module is useful for handling dates in Python.
1) Get Current Date
2) Get Current Date and Time
3) Create and set a Date
4) Create and set a Date and Time
5) Date String Formats

6) Output a Formatted String from a DateTime object
Use the strftime() method from datetime to create a formatted string from a datetime object.
7) Output a Date from a Formatted String
Use the strptime() method from datetime to create a datetime from a formatted string.
8) Get the difference between 2 dates
Use the “-” operator to take the difference between 2 dates.
Outputs timedelta object.
9) Add days to a date to calculate a future date
10) Handle time zones
Use the pytz module to handle time zones.