Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python convert datetime.time to arrow

I need to convert a python object datetime.time to an arrow object.

y = datetime.time()
>>> y
datetime.time(0, 0)
>>> arrow.get(y)

TypeError: Can't parse single argument type of '<type 'datetime.time'>'
like image 560
Alejandro Veintimilla Avatar asked Dec 08 '22 20:12

Alejandro Veintimilla


1 Answers

Arrow follows a specific format, as specified in its documentation:

arrow.get('2013-05-11T21:23:58.970460+00:00')  

you need to convert your datetime object to arrow-understandable format in order to be able to convert it to an arrow object. the codeblock below should work:

from datetime import datetime
import arrow

arrow.get(datetime.now())
like image 53
Prateek Dewan Avatar answered Jan 06 '23 09:01

Prateek Dewan