Skip to content

Instantly share code, notes, and snippets.

@selimslab selimslab/time.py

Created Nov 1, 2019
Embed
What would you like to do?
from datetime import datetime, timedelta
TODAY = datetime.now().date().isoformat()
def get_date_of_x_days_ago(x: int):
return (datetime.now().date() - timedelta(days=x)).isoformat()
def str_to_date(s: str):
return datetime.strptime(s, "%Y-%m-%d").date()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.