Im trying to get from a set of ISO8601
timestampts (sort to say) a correct datetime
object in Python 3.9, the problem comes here:
When trying to parse (for instance) the ISO8601
timestamp 2021-06-25T14:00:00.000Z
into a datetime
object un Python I get a wrong date and time, while if I do it in Javascript with the Date()
object instance I get the correct one; here's in code how I did it:
Python:
from dateutil import parser
output = parser.parse('2021-06-25T14:00:00.000Z')
# output value is:
datetime.datetime(2021, 6, 29, 14, 0, tzinfo=tzutc())
# accessing the hour of that output
output.hour # 14 , it shouldn't be 14
Javascript
output = new Date('2021-06-25T14:00:00.000Z')
// calling output outputs:
Fri Jun 25 2021 09:00:00 GMT-0500 (hora de verano central) // as you can see, it says that is 9am which IS CORRECT
So recap, the Javascript output is the correct and I want such output to be the same as with Python, Why is this happening? how to solve it?
NOTE:
I cannot use javascript obviously so I'm in complete need of doing it by Python 3.9