-1

im getting the datetime value as 2022-08-25T20:35:12.744Z. i need to compare this current datetime and get its difference date time.

from datetime import datetime 
date_time_str='2022-08-25T20:35:12.744Z'
print(datetime.strptime(date_time_str, '%d/%m/%y'))

how to caculate this value into datetime value ?

Gopi
  • 19
  • 3
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community May 31 '22 at 01:37
  • 1
    parse the string to a datetime object [as described here](https://stackoverflow.com/q/127803/10197418) (make sure to parse "Z" to UTC), then compare against `datetime.now(timezone.utc)`. Specifically, see e.g. [here](https://stackoverflow.com/a/62769371/10197418), and [here](https://stackoverflow.com/a/58294845/10197418). – FObersteiner May 31 '22 at 07:07

0 Answers0