DEV Community

loading...
Cover image for #Day8 - Datetime CheatSheet in Python

#Day8 - Datetime CheatSheet in Python

Rahul Banerjee
Comp Eng Student @uoft | My opinions are my own Add me on LinkedIn: https://www.linkedin.com/in/rahulbanerjee2699/
Originally published at realpythonproject.com ・1 min read

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

Discussion (0)

Forem Open with the Forem app