import datetime
my_date = datetime.date.today() # if date is 01/01/2018
year, week_num, day_of_week = my_date.isocalendar()
print("Week #" + str(week_num) + " of year " + str(year))
>>> import datetime
>>> datetime.datetime.today()
datetime.datetime(2012, 3, 23, 23, 24, 55, 173504)
>>> datetime.datetime.today().weekday()
4
from datetime import datetime
date_str='10-12-20'
datetime_object = datetime.strptime(date_str, '%m-%d-%y')
datetime_object.weekday()
today_day = date.today()
days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","sunday"]
print("Today weekday is ",days[today_day.weekday()])
import datetime
now = datetime.datetime.now()
print(now.strftime("%A"))
# int value range: 0-6, monday-sunday
weekday = datetime.weekday()
import datetime
from dateutil.relativedelta import relativedelta
week = 25
year = 2021
date = datetime.date(year, 1, 1) + relativedelta(weeks=+week)
print(date)
Code Example |
---|
:: |
Python :: |
:: |
Python :: |
Python :: |
:: |
Python :: python set day of date to 1 |
:: |
:: |
:: effektivwert python |
:: |
Python :: |
:: |
:: sys.path.append python |
Python :: plot multiple axes matplotlib |
Python :: |
:: |
Python :: |
:: python count array length |
Python :: Find the title of a page in python |
:: how to remove quotes from a string in python |
:: |
:: def function in python |
:: Kill python background process |
:: |
Python :: |
:: |
:: |
Python :: notion python api |
Python :: |