Skip to content Skip to sidebar Skip to footer

Get Right Timezone Information When Using Datetime.datetime.now()?

I'm trying to get the date in datetime.datetime.now() format but for MT time in Python 2.7. If you suggest using a library please explain how to install it. Thanks.

Solution 1:

from pytz import timezone
from datetime import datetime
datetime.now(timezone('US/Mountain'))

That's what you probably need. As for installing the library, just pip install pytz


Post a Comment for "Get Right Timezone Information When Using Datetime.datetime.now()?"