O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Formatting and parsing dates

In all the recipes so far, we performed multiple operations on the date or time objects. But the objects themselves are represented in certain formats. For instance, by default, the date() object is represented in a YYYY-MM-DD format and the time() object is represented in a HH:MM:SS format. While these representations are good, we can't always use these formats for representing data to the users on a website or while scheduling meetings from a web page.

In this section, we quickly look at the different formats in which the date and time objects can be manifested to the users.

Getting ready

For this recipe, we end up using the same datetime module that gets packaged with the default Python installation.

How to do it... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required