To get the current time, “datetime” must be imported from the “datetime” module. When “datetime.now()” is assigned to the variable “now,” the current time is shown when the variable is called.
It is also possible to call in the month,day, and year individually by adding “month,” “year,” and “day with the module “now.”
To put the month, day, and time in mm/dd/yy format, the code must be configured the way it is shown on line 4.
Printing out the time is similar to printing out the date. On line 4 replace the “/” with “:” and replace the functions for month, day, and year with the hour, minute, and second.
The following code shows combining the date and the time so that both are printed out on the same line.The order of the functions must be correct.