-2

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 function I am using:

def utc_to_london(utc_dt):
        tz = pytz.timezone('Europe/London').localize(utc_dt)
        print(tz)
        return tz;

thanks for your help

Rpp
  • 103
  • 1
  • 12

1 Answers1

5

12:39:07+01:00 means "39 minutes past noon in a time zone one hour later than UTC." So it means 11:39 UTC.

There is no circumstance in which it makes sense to "apply" the +1 forward to get 13:39, because that is a nonsensical timezone--you're "doubling" your UTC offset which has no practical meaning.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • The only thing is that 12.39.07 is the utc time now – Rpp Jul 27 '17 at 12:48
  • 3
    It sounds like your problem is that you're taking `12:39:07` and using `tz_localize()` to attach the London time zone to it. Instead, what you need to do is "localize" it to `pytz.utc` then *convert* it to London time. – John Zwinck Jul 27 '17 at 13:31