Reputation: 11
I have timestamps in the format
Sep 12 2019 21:28:11
1 Sep 12 2019 21:28:11
2 Oct 13 2019 21:28:11
3 Oct 14 2019 21:28:11
4 Nov 15 2019 21:28:11
I need to write a python script by which I can get the week number from the date mentioned. Can anyone help me with the same?
Upvotes: 0
Views: 63
Reputation: 1674
Just another option may be isocalendar function https://docs.python.org/3/library/datetime.html#datetime.datetime.isocalendar
>>> import datetime
>>> datetime.datetime.strptime("Sep 12 2019 21:28:11", "%b %d %Y %H:%M:%S").isocalendar()
(2019, 37, 4)
Upvotes: 0
Reputation: 653
Use datetime
module.
import datetime
datetime.datetime.strptime("Sep 12 2019 21:28:11", "%b %d %Y %H:%M:%S").strftime("%V")
Upvotes: 1