#!/usr/bin/env python import time #strtime to timestamp strTime = "2013-11-05 14:51:43" timestamp = time.mktime(time.strptime(strTime,'%Y-%m-%d %H:%M:%S')) print timestamp #timestamp to string time print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timestamp)) #get now timestamp print time.time() #fomate right now timestamp to string time print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) #output #1383634303.0 #2013-11-05 14:51:43 #1383634321.24 #2013-11-05 14:52:01