DEV Community

Cover image for #Day8 - Datetime CheatSheet in Python
Rahul Banerjee
Rahul Banerjee

Posted on • Originally published at realpythonproject.com

#Day8 - Datetime CheatSheet in Python

Today we will be discussing the common operations using the Datetime Library in Python

1. Get Current Datetime

image.png

2. Datetime to a string in the desired format

image.png

Check out this resource more for examples

3. String to Datetime

image.png

4. Getting Week Number from the Date time object

image.png

5. Arithmetic with Datetime

image.png

6. Get all the days in a year

image.png

7. Get all the dates of all Mondays in a year

image.png

8 . Datetime comparison

image.png

9. Difference b/w datetime objects

image.png

10. Timezones

image.png

Top comments (0)