If you want to format a datetime object in a specific format, it is better to explicitly specify the desired format. You can use the below given code:
Input:
import time
time.strftime("%Y-%m-%d %H:%M:%S")
Output:
'2019-08-02 11:42:11'
The above shown code used local time by default, if you need UTC you can use the following:
Input:
time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
Output:
'2019-08-02 11:44:14'