Utilizor
Contact Us

Python Dates

Working with dates.

Examples

Current Date

Prints current date and time.

import datetime

x = datetime.datetime.now()
print(x)

Create Date Object

Creating a specific date.

import datetime

x = datetime.datetime(2020, 5, 17)
print(x)

Strftime

Format date as string (Month name).

import datetime

x = datetime.datetime(2018, 6, 1)

print(x.strftime("%B"))

Test Your Knowledge

Python Quiz

No quiz available for this topic yet.