stack overflow python timedate

>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)

>>> print(datetime.datetime.now())
2009-01-06 15:08:24.789150

Here is what the above code is Doing:
1. Importing the datetime module.
2. Calling the now() function from the datetime module.
3. Printing the current date and time.

The now() function returns the current local date and time.

The datetime module also contains functions and classes for working with dates and times in other ways.

The datetime Module
The datetime module has many functions and classes to represent dates and times.

Here are some important functions and classes in the datetime module:

Function Description
date.today() Returns the current local date
datetime.date Represents a date
datetime.time Represents a time
datetime.datetime Represents a date and time
datetime.timedelta Represents a duration of time
datetime.tzinfo Represents a time zone

The date Class
The date class represents dates.

A date object contains year, month, and day.

You can create a date using the date() class constructor.

The constructor takes three parameters: year, month, and day.

Example
Create a date object:

>>> import datetime
>>> x = datetime.date(2020, 5, 17)
>>> print(x)
2020-05-17

The time Class
The time class represents time.

A time object contains hour, minute, second, and microsecond.

You can create a time using the time() class constructor.

The constructor takes four parameters: hour, minute, second, and microsecond.

Example
Create a time object:

>>> import datetime
>>> x = datetime.time(16, 29, 0)
>>> print(x)
16:29:00

The datetime Class
The datetime class represents date and time.

A datetime object contains year, month, day, hour, minute, second, and microsecond.

You can create a datetime using the datetime() class constructor.

The constructor takes six parameters: year, month, day, hour, minute, and second.

Example
Create a datetime object:

>>> import datetime
>>> x = datetime.datetime(2018, 6, 1)
>>> print(x)
2018-06-01 00:00: