dates the module datetime allows us to work with dates and times together the following line creates datetime object that contains the current date and timefrom datetime import datetime datetime( , , now(the datetime object has attributes yearmonthdayhourminutesecondand microsecond here is short exampled datetime( , , now(print'{}:{: {}/{}/{format( hour, minute, month, day, year) : the hour is in -hour format to get -hour formatyou can do the followingam_pm 'am if hour< else 'pm print'{}:{}{format( hour% minuteam_pm)an alternative way to display the date and time is to use the strftime method it uses variety of formatting codes that allow you to display the date and timeincluding information about the day of the weekam/pmetc here are some of the formatting codescode description % date and time formatted according to local conventions % % % is the dateand % is the timeboth formatted as with % % day of the month % day of the year % % weekday name (% is the abbreviated weekday name% month ( - % % month name (% is the abbreviated month name% % year (% is -digit% is -digit% % hour (% is -hour% is -hour% am or pm % minute % second here is an exampleprint( strftime'% % ')tuesday here is another exampleprint( strftime'% ')print( strftime'% % on % % ')