Date Time Formats in Python

That extra .000 is micro seconds.

This will convert a date string of a format to datetime object.

import datetime
d1 = datetime.datetime.strptime("2013-07-12T07:00:00Z","%Y-%m-%dT%H:%M:%SZ")
d2 = datetime.datetime.strptime("2013-07-10T11:00:00.000Z","%Y-%m-%dT%H:%M:%S.%fZ")

Then convert them into any format depending on your requirement, by using:

new_format = "%Y-%m-%d"
d1.strftime(new_format)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)