Date will be displayed with only 1 digit


#1

I got stuck in the Grand Final of Time and Date, because when i use the code:

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)

python shows me 6/13/2016 (and than the time) - so the Zero in front of the month 6 is missing!!! has anybody a hint what i can do to solv this?

Thanks a lot!


#2

the zero in front of the 6 is not the problem. The problem is you use backslashes \, where you should forward slashed /


#3

I did the same thing with both forward slashes and it still dosen't print with a 0 before.

from datetime import datetime
now = datetime.now()

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

So that's obviously not the problem.


#4

this answers was specifically written for OP, if you have a question please make a new topic