Wednesday, July 16, 2014

How to get today's date in MM/DD/YYYY format

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


How this works - Line by Line

import time                           #1

Imports the time module which is standard

print time.strftime("%m/%d/%Y")       #2

Prints the date in "MM/DD/YYYY" format. Note the lower case m and d and upper case Y.

No comments:

Post a Comment