import time tstr = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())) print tstr