%02d and %04d in python date and time


The above link provides the lesson about date and time. I really don’t understand what is %02d and %04d. What are they? What role do they play?

Hello @adamhaller0836239377, welcome to the forums! As far as I know, they mean display this with 2 or 4 digits-respectively.

1 Like

See the following for information on formatting techniques that can be used with both Python 2 and Python 3:

With Python 3.6 or later, we can also use f-strings, described here:

There’s lots of additional information available regarding these techniques that can be found via search.