2.1.1. 当前时间转换为时间戳:getCurTimestamp

from datetime import datetime,timedelta;

#------------------------------------------------------------------------------
# get current time's timestamp
def getCurTimestamp() :
    return datetimeToTimestamp(datetime.now());

#------------------------------------------------------------------------------
# convert datetime value to timestamp
# from "2006-06-01 00:00:00" to 1149091200
def datetimeToTimestamp(datetimeVal) :
    return int(time.mktime(datetimeVal.timetuple()));
        

例 2.1. getCurTimestamp使用范例

curTimestamp = getCurTimestamp();
jsonp = "jsonp" + str(curTimestamp);