Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Python datetime object does not change date light saving automatically when setting day

$
0
0

I am in NZ and we just ended daylight saving on 7th April, when I change the day of the object back to before daylight saving ends, it does not update the timezone back to +13.

from django.utils import timezoneIn [8]: timestamp = timezone.localtime(timezone.now())In [9]: print(timestamp)2024-04-09 14:20:58.907339+12:00In [10]: timestamp = timezone.localtime(timezone.now()).replace(day=1, hour=19, minute=0, second=0)In [11]: print(timestamp)2024-04-01 19:00:00.784648+12:00

I have had a quick glance over this https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html but it was talking about timedelta, is this a known issue?

enter image description here


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>