Get day of year from python arrow

1k views Asked by At
_date = '2017-03-17T00:00:00'

import arrow
arrow.get(_date)

How can I get day of year from the above code?

2

There are 2 answers

1
Anton vBR On BEST ANSWER

You are asking for the arrow solution, but here as an alternative with datetime library.

As explained by: Converting python time stamp to day of year this would be the answer you are seeking:

import datetime
_date = '2017-03-17T00:00:00'
dt = datetime.datetime.strptime(_date, '%Y-%m-%dT%H:%M:%S')
print(dt.timetuple().tm_yday)
# prints 76
0
Song On

You can also use arrow.now().format("DDDD").