Skip to content

Instantly share code, notes, and snippets.

@POMXARK
Created June 4, 2024 08:25
Show Gist options
  • Save POMXARK/9c4cd9e69c4ebd5020693c4c3f2fd0cf to your computer and use it in GitHub Desktop.
Save POMXARK/9c4cd9e69c4ebd5020693c4c3f2fd0cf to your computer and use it in GitHub Desktop.
expiration_date
# python = 3.9.4
import datetime
now = datetime.datetime.now()
print(now.strftime("%d.%m.%Y %H:%M:%S"))
date_today = now.strftime("%a %b %d 8:00:00 %Y")
date_today = datetime.datetime.strptime(date_today, "%a %b %d %H:%M:%S %Y")
date_today_f = date_today.strftime("%d.%m.%Y %H:%M:%S")
def expiration_date(number_of_hours):
date_plus_hours = date_today + datetime.timedelta(hours=number_of_hours)
return date_today_f, number_of_hours, date_plus_hours.strftime("%d.%m.%Y %H:%M:%S")
print(expiration_date(36))
print(expiration_date(72))
print(expiration_date(140))
print(expiration_date(120))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment