'Get day of year from python arrow
_date = '2017-03-17T00:00:00'
import arrow
arrow.get(_date)
How can I get day of year from the above code?
Solution 1:[1]
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
Solution 2:[2]
You can also use arrow.now().format("DDDD")
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Wai Ha Lee |