Questions tagged [pytz]

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.3 or higher. It also solves the issue of ambiguous times at the end of daylight savings.

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.3 or higher. It also solves the issue of ambiguous times at the end of daylight savings.

717 questions
-1
votes
1 answer

How to get modification date of a template file with local timezone in python flask

I have a problem in getting file modified date with local timezone.It always shows the datetime in server default timezone.I have to change it to indian time.(Asia/Kolkata). I have pytz installed ,but i don't know how to use it to change the server…
ping pong
  • 29
  • 1
  • 1
  • 4
-1
votes
1 answer

Adjusting a datetime by a given offset

python 3.8.0 (But could update to higher if neccesary) Users in my system can set their timezone, which is stored as a string, e.g. Europe/London. Using this, I can work out their offset compared to the server time (UTC), so for example a user who…
CMR
  • 1,366
  • 4
  • 15
  • 31
-1
votes
2 answers

UTC to CST time conversion using pytz python package

I have nested json file which has time zone which is in UTC format I am capturing that and putting it into a column and then trying to convert that to cst by creating a column for CST but it is not converting can anybody help am posting the code…
user13073332
  • 21
  • 1
  • 7
-1
votes
1 answer

default datetime.now value on entries doesnt change unless flask server restarted

Ive noticed that when I submit an entry in my forms page, the date_input will repeat on consequent submissions unless restarted. Why is this happening? I swear that the duplicate times were minutes apart but it seems that the submitted time is only…
roocs
  • 43
  • 1
  • 9
-1
votes
1 answer

Converting timezones using pytz on Pandas Series

I am trying to convert the timezone of a pandas Series. I am using the pytz package to do so, however I am getting a value that is off by a few minutes. The code I am currently using can be found in the answer here: Converting Items from Pandas…
ohoh7171
  • 186
  • 2
  • 2
  • 14
-1
votes
1 answer

How to get the UTC offset from a timezone string using pytz?

I am trying to get the UTC offset as a string from my timezone using the Python library pytz. I am defining it as follows: import pytz tz = pytz.timezone('Africa/Cairo') Now, I want to get '+02:00' from the tz variable, as that is the…
darkhorse
  • 8,192
  • 21
  • 72
  • 148
-1
votes
1 answer

Why does it make a difference if I add 1 hour to the UTC time and localize or 1 hour to the local time?

Example Code from datetime import datetime, timezone, timedelta import pytz t11 = datetime(1918, 4, 15, 0, 0, tzinfo=timezone.utc).astimezone(pytz.timezone('Europe/Berlin')) t12 = t11 + timedelta(hours=1) t2 = datetime(1918, 4, 15, 1, 0,…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
-1
votes
1 answer

Converting and calculating timezone for datetime objects in python with proper dates

How can we find time difference between two different time zones? what i mean is,if i have two different times of different time zones: d1=datetime.datetime(2017, 8, 7, 22, 30, tzinfo='Asia/Kolkata' LMT+5:53:00 STD>) d2=datetime.datetime(2017, 8, 8,…
-1
votes
2 answers

unable to display time in different timezone

When I change tzinfo on an aware datetime instance I keep getting the same strftime result: >>> from datetime import datetime >>> import pytz >>> fmt = '%d.%m.%Y %H:%M' >>> now_naive = datetime.utcnow() >>> now_naive.strftime(fmt) '02.08.2017…
kurtgn
  • 8,140
  • 13
  • 55
  • 91
-1
votes
1 answer

Convert US/Eastern to UTC including daylight savings Python

I was really surprised to not find an easy way to do this in Python. We wrote this in December and it passed, because it was winter: def get_utc_time(dt_or_str, number_of_days=None, time_format=DATETIME_FORMAT): """ :param dt_or_str: …
codyc4321
  • 9,014
  • 22
  • 92
  • 165
-1
votes
1 answer

fractions of seconds and pytz: do you have a cleaner solution?

I have times in a log that look like this: 1440498131.372625 What I've done using pytz is utc = pytz.utc for anra in raFromMCCS: fsecs = float(anra.time) isecs = int(fsecs) isec2 = int(fsecs * 1000) dt =…
evernoob
  • 103
  • 7
-2
votes
1 answer

Converting timezone using pytz

I have converted a timezone to 'Europe/London' which prints out: 2017-07-27 12:39:07+01:00 as London time which is correct. But how to I get this to print the time with that +01:00 added onto it so it would be 13.39.07 in this case? This is the…
Rpp
  • 103
  • 1
  • 12
1 2 3
47
48