CHAPTER 42   •   PYTHON

Python Dates

Learn how to work with dates using the datetime module.

01 What is this?

Learn how to work with dates using the datetime module.

02 Syntax

Python Syntax
datetime.now()

03 Example

Python Example
from datetime import datetime

now = datetime.now()
print(now)

04 Important Points

The datetime module provides date and time functionality.

05 Common Mistakes

Be careful about date and time formatting.

06 Real World Use

Dates are required for bookings, reports and records.

07 Practice This Topic

Now try the example yourself in the AIFA Python Editor.

  • Read the example carefully.
  • Change the values.
  • Run the code.
  • Observe the output.
  • Try creating your own example.
Try It Yourself →