Curious Lambda Curious Lambda - 3 months ago 26
Python Question

What does the utcoffset method do in datetime - Python

I know this questions answer is usually "go to Python's documentation". I have read it and am still not a 100% sure what the uctcoffset method does.

I assume that it takes the timezone - utc and gives the difference but I need to be 100% sure.


yes, it is doing exactly what you think it does. Here are the official docs.

Edit: To be precise, it does not take a timezone, it takes 0 paramters. You invoke it on a datimeobject, that object has a timezone associated to it, if it is timezone aware. In that case the method wil return a timedelta object, which represents the differenc between the timezone of the datetime object and utc