Bem vindo!
This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
Subtração de horas e horas em portugues com datatime Python
Como somar ou subtrair duas horas com Ano,Mes,Dia,Hora,Minuto e segundo. A hora atual string_day vai ser convertida de string para datatime.
from datetime import datetime
last_day = datetime.strptime( string_day ,'%Y-%m-%dT%H:%M:%S').strftime("%Y-%m-%d %H:%M:%S") now_day = datetime.now().strftime("%Y-%m-%d %H:%M:%S") sec = datetime.strptime(now_day,"%Y-%m-%d %H:%M:%S") - datetime.strptime(last_day,"%Y-%m-%d %H:%M:%S")
Outras operações e formatação com horas:
www.programiz.com/python-programming/datetime/strftimedatetime/strftime
Horas em Posrtugues:import locale from datetime import datetime locale.setlocale(locale.LC_TIME, 'pt_BR.utf8') print datetime.now().strftime('%A %d de %B de %Y, %H:%M:%S')
print datetime.datetime.now().strftime('%A %d de %B de %Y')
Your Answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Fique Informado
Sobre esta Comunidade
Moderation Tools
Ferramentas de Pergunta
Estatísticas
Perguntada: 07/06/21 13:54 |
Visto: 871 vezes |
Última atualização: 03/06/22 16:47 |