From the course: Python Standard Library Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Date and time formatting

Date and time formatting - Python Tutorial

From the course: Python Standard Library Essential Training

Start my 1-month free trial

Date and time formatting

- Now that we've seen how to construct various date and time classes let's take a look at the different options available for presenting this information to the user the main functions available for formatting date and time information is the strfttime function and it works in a similar way to the regular string format function in that it provides a set of control codes that indicate how a particular part of a date or time should be represented so here in the docks for datetime, if you click on the link for strftime behavior that will take you to this part of the page in if I scroll down you can see all the various formatting control codes that are available and there's lot of them so I'll let you review this on your own time and experiment so for now let's jump into the code and try some of these out. So here in my dtformat_start file I've already created a variable to hold the current date and time so let's try different ways of printing things like day and month names and parts of…

Contents