I\'m using the datetime module, i.e.:
>>> import datetime
>>> today = datetime.datetime.now()
>>> print(today)
2009-03-06 13:24:58.
You could use strftime with a %j format string:
>>> import datetime
>>> today = datetime.datetime.now()
>>> today.strftime('%j')
'065'
but if you wish to do comparisons or calculations with this number, you would have to convert it to int()
because strftime()
returns a string. If that is the case, you are better off using DzinX's answer.