Assignment#6: Date and Time

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.

date-and-time-1

It is also possible to call in the month,day, and year individually by adding “month,” “year,” and “day with the module “now.”

date-and-time-2

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.

date-and-time-3

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.

date-and-time-4

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.

date-and-time-5