Python Dates and Times in Python Dates and Times Manipulating Time Already

tariqasghar
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
tariqasghar
UX Design Techdegree Graduate 28,226 Points

datetime.now() method return type.

Hello,

I noticed whenever datetime.now() was called or any variable storing the datetime was accessed in the REPL in the video, the value returned was something like datetime.datetime(something).

What type of return type is this?

2 Answers

Steven Parker
Steven Parker
204,010 Points

That's a datetime object. The REPL is just making it into something readable for you when you use it by itself.

For more details see the Python documentation pages.

jhon white
jhon white
19,639 Points
from datetime import datetime

# datetime object containing current date and time
now = datetime.now()
#You can use "type" function to find out. 
print("now =", type(now))

Good luck :)