Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom date format parsing in python

I am trying to the parse dates of the format '2016-04-15T12:24:20.707Z' in Python, tried strptime, doesn't work and I also tried django parse_datetime but it only returns none as the value

like image 652
Amogha Varsha Avatar asked Apr 19 '26 21:04

Amogha Varsha


1 Answers

You may try this way :

from datetime import datetime
date_str = '2016-04-15T12:24:20.707Z'
date = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S.%fZ")

print(date)

Output:

2016-04-15 12:24:20.707000
like image 108
Md. Rezwanul Haque Avatar answered Apr 22 '26 22:04

Md. Rezwanul Haque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!