2.1.4. 将本地GMT8时间转换为GMT标准时间:convertLocalToGmt

from datetime import datetime,timedelta;

#------------------------------------------------------------------------------
# convert local GMT8 to GMT time
# note: input should be 'datetime' type, not 'time' type
def convertLocalToGmt(localTime) :
    return localTime - timedelta(hours=8);
        

例 2.4. convertLocalToGmt的使用范例

gmtTime = convertLocalToGmt(parsedLocalTime);