Wednesday, July 16, 2014

How to print out the current date time in the format mm/dd/yyyy hh:mm:ss

Code
import time                                          #1
print time.strftime("%m/%d/%Y %H:%M:%S")             #2


How this works - Line by Line

import time                                    #1

Imports the time module which is standard

print time.strftime("%m/%d/%Y %H:%M:%S")       #2

Prints the date and time in "MM/DD/YYYY HH:MM:SS" format.
Note that the code is case sensitive.

No comments:

Post a Comment