Reputation: 1
is it possible to format datetime object with strftime with timezone offset?
I do have unix timestamp let say 1658123953
converted to python timezone aware datetime object
datetime.datetime(2022, 7, 18, 7, 59, 13, tzinfo=<DstTzInfo 'Europe/Bratislava' CEST+2:00:00 DST>)
and I would like to apply strftime('%H:%M:%S')
on datetime object to get formatted string with timezone offset added.
I need it in this format
'09:59:13' # with timezone offset added
but I was only able to get this
'07:59:13 +02:00' # not correct format for my case
Upvotes: 0
Views: 983
Reputation: 281
Your UNIX Timestamp is
1658123953
in UTC this is
Mon Jul 18 2022 05:59:13
So this is
07:59:13 +02:00
the Right Timezone Aware Value
You can Check the Unix Timestamp https://www.unixtimestamp.com/index.php
The Timezone Offset is already added in youre String the "+02:00" is just a reference to the Timeoffset
Upvotes: 1