S
S
Salavat Sharapov2015-06-24 08:29:49
Django
Salavat Sharapov, 2015-06-24 08:29:49

How to parse Datetime knowing the timezone?

Good afternoon!
Such a date comes into view 06/23/2015 13:52 , is it known in which timezone it is, how to parse it and write it to the database in UTC?
Undercode

import datetime
date = '23.06.2015 13:52'
parse_date = datetime.datetime.strptime(date, "%d.%m.%Y %H:%M")
dt_utc = pytz.timezone(utc).localize(parse_date)
print dt_utc
2015-06-23 13:52:00+00:00

Also the question is why is date considered absolute?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tplus, 2015-06-24
@desperadik

With examples for both version 2 and version 3:
stackoverflow.com/questions/4563272/how-to-convert...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question