Last active
October 16, 2017 20:57
-
-
Save juanPaclan/bd0381f9c54391b42adf98431ae010d8 to your computer and use it in GitHub Desktop.
instalar pytho-dateutil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil.easter import * | |
from dateutil.relativedelta import * | |
from dateutil.rrule import * | |
from dateutil.parser import * | |
from datetime import * | |
# pip install python-dateutil | |
fecha-actual = datetime.today() | |
johnbirthday = datetime(2017, 10, 15, 10, 25) | |
resultado = relativedelta(fecha-actual, johnbirthday) | |
print(resultado) | |
print(resultado.days, 'dias',resultado.hours, 'horas', resultado.minutes, 'minutos') | |
funcion: | |
fecha= '2017-10-15 10:25' | |
def diferencia(fecha): | |
formato_fecha = "%Y-%m-%d %H:%M" | |
fecha_inicial = datetime.strptime(fecha, formato_fecha) | |
fecha_actual = datetime.today() | |
resultado = relativedelta(fecha_actual, fecha_inicial) | |
return resultado | |
resultado= diferencia(fecha) | |
print(resultado) | |
print(resultado.days, 'dias',resultado.hours, 'horas', resultado.minutes, 'minutos') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment