DateTime and TimeDelta Modules

Hello and thank you for reading this weeks blog post. Unfortunately, I missed last week, but I’m back at it this week! This evening we’re going to discuss two popular Python modules; DateTime and TimeDelta. There are numerous use cases for utilizing these two modules in every day programming.

DateTime is a simple yet extremely useful. You’re able to utilize the DateTime module by first importing it from the Python utilities. As shown below a few examples of the DateTime module include getting the current date, and utilizing an extension method of the module to parse out the time from the date time object.

TimeDelta is another extension method from the date time object that is extremely useful. When you include the extension method TimeDelta you’re able to retrieve and set various aspects of the date time object itself. For example, the below snippet of code utilizes TimeDelta to extract the date, add various seconds, minutes, days, and years to the date time object, which are then displayed to the console.

For example of the above code please feel free to visit my GitHub page: https://github.com/joshsnyder/python-data-science/tree/develop/module7

Thanks for stopping by this week’s blog!!

Leave a comment

Design a site like this with WordPress.com
Get started