Created
June 4, 2024 08:25
-
-
Save POMXARK/9c4cd9e69c4ebd5020693c4c3f2fd0cf to your computer and use it in GitHub Desktop.
expiration_date
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
# 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