[Python] How to convert local time string to UTC?

Discussão em 'Python' iniciado por Stack, Agosto 13, 2025.

  1. Stack

    Stack Membro Participativo

    How do I convert a datetime string in local time to a string in UTC time?

    I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.

    Clarification: For example, if I have 2008-09-17 14:02:00 in my local timezone (+10), I'd like to generate a string with the equivalent UTC time: 2008-09-17 04:02:00.

    Also, from http://lucumr.pocoo.org/2011/7/15/eppur-si-muove/, note that in general this isn't possible as with DST and other issues there is no unique conversion from local time to UTC time.

    Continue reading...

Compartilhe esta Página