Skip to Content
Learn
Date and Time
Getting the Current Date and Time

We can use a function called datetime.now() to retrieve the current date and time.

from datetime import datetime print datetime.now()

The first line imports the datetime library so that we can use it.

The second line will print out the current date and time.

Instructions

1.

Create a variable called now and store the result of datetime.now() in it.

Then, print the value of now.

Folder Icon

Take this course for free

Already have an account?