programming-examples/python/Date/Python program to convert Year Month Day to Day of Year.py

4 lines
138 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import datetime
today = datetime.datetime.now()
day_of_year = (today - datetime.datetime(today.year, 1, 1)).days + 1
print(day_of_year)