fork download
  1. from datetime import datetime
  2. import pytz
  3.  
  4. dt = datetime.strptime("01/01/2018 13:00:40", "%d/%m/%Y %H:%M:%S")
  5. # setar o timezone (sem conversão)
  6. dt = pytz.timezone('America/Sao_Paulo').localize(dt)
  7. # converter para UTC
  8. dt = dt.astimezone(pytz.utc)
  9. print(dt.strftime("%Y-%m-%dT%H:%M:%S%Z").replace('UTC', 'Z'))
  10.  
Success #stdin #stdout 0.06s 11444KB
stdin
Standard input is empty
stdout
2018-01-01T15:00:40Z