Get system local timezone in python -
seems strange, cannot find easy way find local timezone using pandas/pytz in python.
i can do:
>>> pd.timestamp('now', tz='utc').isoformat() out[47]: '2016-01-28t09:36:35.604000+00:00' >>> pd.timestamp('now').isoformat() out[48]: '2016-01-28t10:36:41.830000' >>> pd.timestamp('now').tz_localize('utc') - pd.timestamp('now', tz='utc') out[49]: timedelta('0 days 01:00:00')
which give me timezone, not best way it... there command in pytz or pandas system time zone? (preferably in python 2.7 )
i don't think possible using pytz
or pandas
, can install python-dateutil or tzlocal:
from dateutil.tz import tzlocal datetime.now(tzlocal())
or
from tzlocal import get_localzone local_tz = get_localzone()
Comments
Post a Comment