G
G
GreenX52020-06-10 08:01:15
Python
GreenX5, 2020-06-10 08:01:15

Python Translate this time format Jun 03 01:15 PM?

Good afternoon, it was not possible to google about AM / PM, can you help incoming
Jun 03 01:15 PM
translate into
3 Jun 21:15,
respectively, adding 7 hours of difference in time zones? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-06-10
@GreenX5

>>> from datetime import timedelta, datetime
>>> some_date = datetime.strptime('Jun 03 01:15 PM', '%b %d %I:%M %p')
>>> some_date
datetime.datetime(1900, 6, 3, 1, 15)
new_date = (some_date + timedelta(hours=7)).strftime('%e %b %H:%M')
>>> new_date
' 3 Jun 20:15'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question