Lab 3: Date & Time

Lab 3: Date & Time

Lab Description:

In this lab we had to code the time and date. I had a little trouble at first trying to figure out the final steps. I was having problems getting the date to read out mm/dd/yyyy, but after a long while I was able to grasp the concept and get it. After I was able to past that section and I knew what to do, the other parts were easy such as coding the hours, minutes, and seconds then combing them with the date.

Code:

from datetime import datetime
now = datetime.now()
year = now.year
month = now.month
day = now.day
hour = now.hour
minute = now.minute
second = now.second
print str(month) + “/” + str(day) + “/” + str(year), str(hour) + “:” + str(minute) + “:” + str(second)

Screenshot:

date and time

Leave a Reply

Your email address will not be published. Required fields are marked *