Codecademy Python Answers Date and Time

Date And Time 1/6 – The Date Library

from datetime import datetime

Date And Time 2/6 – Getting the Current Date and Time

from datetime import datetime
now = datetime.now()
print now

Date And Time 3/6 – Extracting Information

from datetime import datetime
now = datetime.now()
print now
print now.year
print now.month
print now.day

Date And Time 4/6 – Hot Date

from datetime import datetime
now = datetime.now()

print '%s/%s/%s' % (now.year, now.month, now.day)

Date And Time 5/6 – Pretty Time

from datetime import datetime
now = datetime.now()
print '%s:%s:%s' % (now.hour, now.minute, now.second)

Date And Time 6/6 – Grand Finale

from datetime import datetime
now = datetime.now()
print '%s/%s/%s %s:%s:%s' % (now.month,now.day,now.year,now.hour, now.minute, now.second)

 

Also Read :   Codecademy Python Answers Python Syntax

Leave a Reply

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