print str(now.month) + str(now.day) + str(now.year)
Result: 1162014
How do I further format the result to add slashes: 11/6/2014
Also how would I do formatting for hour, minute, and second? hh:mm:ss
Displaying datetime as month/day/year & hours:minutes:seconds:
import datetime
now = datetime.datetime.now()
print datetime.datetime.strftime(now, '%m/%d/%Y')
print datetime.datetime.strftime(now, '%H:%M:%S')
Displaying datetime as month/day/year & hours:minutes:seconds on one line:
import datetime
now = datetime.datetime.now()
print datetime.datetime.strftime(now, '%m/%d/%Y %H:%M:%S')
special thanks to senshin for the help
%mmeans "month", while uppercase%Mmeans "minute".