Skip to content

Convert date object in normal format

When I am using a Python object, I get:

2018-05-18 08:38:58+00:00

This is not the format I need. We need to convert to this data format:

2018-05-18 08:38:58

How can I convert this in Python/Django?


datetime.datetime.strptime('2018-05-18 10:05:06', "%Y-%m-%d %H:%M:%S")

It’s working fine, but how can I pass 2018-05-18 10:05:06 as database but database giving?

2018-05-18 08:38:58+00:00
infoDevice = Device.objects.get(
newDate = Device.last_notification_time

It’s giving 2018-05-18 08:38:58+00:00.

How can I check date as per 2018-05-18 08:38:58?



Now I have implemented code for Python changes. Now it’s working. We need to just change the time setting.

Get any date from the database and change as required.

newDateFor = str(info.dbdatetime)
new_dt = newDateFor.split('+')[0]
newDate = datetime.datetime.strptime(new_dt, "%Y-%m-%d %H:%M:%S")
a =
b = newDate

Implement any other functionality as per changes.