Datetime

Create timezone aware datetime object in Python

In this article, we will discuss how to create a timezone-aware datetime object in Python. It means the tzinfo attribute in the datetime object should not be empty and contain the specified timezone info. In Python’s datetime module, the datetime class has an attribute tzinfo, which contains the timezone information. If you create a naive …

Create timezone aware datetime object in Python Read More »

Python: Convert timedelta to milliseconds

This article will discuss how we can convert the datetime module’s timedelta object to total milliseconds in python. Background: In Python’s datetime module, the datetime.timedelta represents the duration between two dates, time, or datetime objects. For example, we have two timestamps as datetime objects, If you want the difference between these two timestamps, you can …

Python: Convert timedelta to milliseconds Read More »

Convert timedelta to seconds in Python

This article will discuss how we can convert the datetime module’s timedelta object to total seconds in python. A little insight about the problem in hand, In the datetime module, the datetime.timedelta represents the difference between two dates, time, or datetime objects. For example, we have two timestamps as datetime objects, If you want the …

Convert timedelta to seconds in Python Read More »

Scroll to Top