Advertisement
JPablos

días_este_año

Feb 28th, 2025
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | Source Code | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """
  4. Creado Vie Feb 28 2025 15:26:10
  5.  
  6. Este código calcula los días de año en curso que han pasado.
  7.  
  8. Truco para que la fecha de inicio sea automáticamente el 1 de enero del año
  9. actual.
  10.  
  11. """
  12.  
  13. from datetime import datetime
  14.  
  15. # Obtener el primer día del año actual
  16. inicio_anio = datetime(datetime.now().year, 1, 1)
  17.  
  18. # Obtener la fecha y hora actual
  19. hoy = datetime.now()
  20.  
  21. # Calcular la diferencia de tiempo
  22. diferencia = hoy - inicio_anio
  23.  
  24. # Mostrar el resultado
  25. print(f"Han pasado {diferencia.days} días desde el inicio del año hasta hoy.")
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy